I have some code that forks a third-party application and redirects its standard output to the parent process, roughly as follows (no error handling here for brevity): I have no code for the third-party application, it is a proprietary binary. When running the third-party application in a terminal with the same arguments as used in the code above, it eventually
Tag: zombie-process
read() hangs on zombie process
I have a while loop that reads data from a child process using blocking I/O by redirecting stdout of the child process to the parent process. Normally, as soon as the child process exits, a blocking read() in this case will return since the pipe that is read from is closed by the child process. Now I have a case
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
Creating “background running” children with fork() and kill each of them with signals
I need to create n children from the same parent, and have them running while the parent asks infinitely for a signal to send to some child. I made the parent create those n children, but they finished executing, so I made them enter a while(1) loop. The problem is, when I try to kill any child, it becomes a
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
Linux, waitpid, WNOHANG, child process, zombie
I running my program as daemon. Father process only wait for child process, when it is dead unexpected, fork and wait again. But when child process being killed with -9 signal, the child process goes to zombie process. waitpid should return the pid of child process immediately! But waitpid got the pid number after about 90 seconds, Here is the