Tugger the SLUGger!SLUG Mailing List Archives

[no subject]


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.