The manual for wait/waitpid states
A child that terminates, but has not been waited for becomes a "zombie". The kernel maintains a minimal set of information about the zombie process (PID, termination status, resource usage information) in order to allow the parent to later perform a wait to obtain information about the child. As long as a zombie is not removed from the system via a wait, it will consume a slot in the kernel process table, and if this table fills, it will not be possible to create further processes. If a parent process terminates, then its "zombie" children (if any) are adopted by init(8), which automatically performs a wait to remove the zombies.
And
The waitpid() system call suspends execution of the current process until a child specified by pid argument has changed state. By default, waitpid() waits only for terminated children, but this behaviour is modifiable via the options argument, as described below.
<snip>...
WNOHANG
return immediately if no child has exited.
I'm creating a Linux command interpreter and must be able to execute tasks in the background, per assignment. But I don't want them to leave a zombie when they finish. Does WNOHANG prevent zombie status even if I call it right after I fork? Or do I have to poll my background children? In short, does one call to waitpid(pid, NULL, WNOHANG) count as "been waited for," above.
Linux wait - does WNOHANG prevent process zombies?
Moderator: Coders of Rage
- MarauderIIC
- Respected Programmer
- Posts: 3406
- Joined: Sat Jul 10, 2004 3:05 pm
- Location: Maryland, USA
Linux wait - does WNOHANG prevent process zombies?
Last edited by MarauderIIC on Tue Feb 10, 2009 9:56 pm, edited 3 times in total.
Reason: WNOHANG, in short
Reason: WNOHANG, in short
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.