If I have a script (process run.py) that will run 3 subprocesses A.py, B.py, C.py (3 scripts called at same time through process run.py). The operation is fine. However say in b.py i have a line such as (pref) How can i get subprocess of A.py and c.py to wait/pause for 5seconds, in order for user to enter y or
Tag: wait
How to wait() only for some child processes and prevent zombies
I’m trying to write a mock-shell in c on linux, and got stuck on this problem: I need to run some processes in the background, and some processes in the foreground. To prevent the foreground processes from becoming zombies, I can use wait(), but how do I prevent the background processes from becoming zombies? Answer You cannot prevent any process
Wait for signal, then continue execution
I am trying to make a program that suspends its execution until a signal arrives. Then, after the signal arrives I just want my code to continue its execution from where it was. I don’t want it to execute a function handler or whatsoever. Is there a simple way of doing this? I have been struggling for a week or
Can someone please explain how this works?fork(),sleep()
What is happening here? How is sleep() getting executed in the for loop? When is it getting called? Here is the output: Please explain this output. I am not able to understand how it’s working. Step by step analysis would be great. Answer In the first loop, the original (parent) process forks 10 copies of itself. Each of these child
C wait3() int* status or int* stat_loc
I indeed to use wait3(). I have been looking what exactly is status/stat_loc but I couldn’t find it anywhere. Any explanation is greatly appreciated! Answer man wait explains the semantics of status:
Wait until a certain process (knowing the “pid”) end
I have this: Then i do this: I think this is not the best way to wait for the process to terminate, there must be some function wait or something, but i can’t find it. Disclaimer: The process is not a child process Answer I’m not really a Python programmer, but apparently Python does have os.waitpid(). That should consume less