Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
82 views
in Technique[技术] by (71.8m points)

c - child process in the background using (ls &)

I am making my own shell using C, if I use & at the end of the command then it will run in the background.. So to make it run in the background I don't use a wait() in the parent.

My code runs like this when I am not using &

-->ls
File1.c file2.c file.txt
-->

where I am printing --> before taking the user input for the next command.

But if I use & at the end, I have just tried this with ls

My code runs like this:

-->ls &                              (line 1)
-->File1.c file2.c file.txt          (line 2)
                                     (line 3)

So after this the cursor is at the line 3.. Now to print another prompt sign -->, I need to hit enter and it shows a prompt in a line after line 3

I want the output to look like this without pressing enter

-->ls &
-->File1.c file2.c file.txt
-->

what can I do?

question from:https://stackoverflow.com/questions/65906012/child-process-in-the-background-using-ls

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...