> So there you go.
 
> Zombies? From said book:
 
> ----------
> You cannot kill zombies; they are already dead.
 
> [cut]
 
> So, to get rid of a zombie, you must wait for it. If you have already
> done so or if the process' PPID is 1, the process is almost certainly
> stuck in a device driver close routine, and if it remains that way
> forever, the driver has a bug.

Parents have to wait() for child processes or they become zombies.
I was reading about this on the train this morning, it pops up now and
again. The following explanation re zombies looks pretty good and should
be applicable to Linux. 

>From "Unix Internals: The New Frontiers" by Uresh Vahalia, Prentice Hall.

2.8.7 Zombie Processes

When a process exits, it remains in zombie status until cleaned up by its
parent. In this state, the only resource it holds is a proc structure,
which retains its exit status and usage information, (footnote: Some
implementations use a special zombie structure to retain this
data). This information may be important to the parent. The parent
retreives this information by calling wait(), which also frees the
proc structure. If the parent dies before the child, the init process
inherits the child. When the child dies, init calls wait() to release
the child's proc structure.

A problem may arise if a process dies before its parent and the parent
does not call wait(). The child's proc structure is never released, and
the child remains in the zombie state until the system is
rebooted. This situation is rare, since the shells are written
carefully to avoid this problem. It may happen, however, if a
carelessly written application does not wait for all child
processes. This is an annoyance, because zombies are visible in the
output of ps (and users are vexed to find that they cannot be killed-
they are already dead). Furthermore, they use up a proc structure,
therby reducing the maximum number of processes that can be active.

Some newer UNIX variants allow a process to specify that it will not
wait for its children. For instance, in SVR4, a process may specify
the SA_NOCLDWAIT flag to the sigaction call to specify the action for
SIGCHLD signals. This asks the kernel not to create zombies when the
caller's children terminate.

Stuart.


-- 
SLUG - Sydney Linux User Group Mailing List - http://slug.org.au/
More Info: http://slug.org.au/lists/listinfo/slug

Reply via email to