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 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…