No subject
Sat Dec 22 01:44:03 NZDT 2007
NOTES
A child that terminates, but has not been waited for becomes a "zom-
bie". The kernel maintains a minimal set of information about the zom-
bie 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.
So, as long as the parent is alive, defunct children will be kept around.
If it is not possible/convenient to have the parent wait on the
children, the parent should fork off grandchildren (instead of
children) as follows:
1) Parent forks child and calls wait
2) Child forks grandchild
3) Child exits causing parent's wait call to return
4) <time passes>
5) Grandchild exits. Child is already dead, so init adopts grandchild
and calls wait. Grandchild is then automatically removed.
-mpb
More information about the gobolinux-users
mailing list