Wednesday, February 27, 2008

UNIX Zombie Process

Defunct processes, also known as "zombie" processes, are those that for some reason lose the handle to the parent, or the parent loses the handle to the child process, so the last step of cleanup does not occur when the process finishes.

When a process dies, it becomes a zombie process. Normally, the parent performs a wait() and cleans up the PID. But the parent can handle only one signal at a time, and sometimes the parent receives too many SIGCHLD signals at once. It is possible to resend the signal on behalf of the child via kill -18 PPID. Killing the parent or rebooting will also clean up zombies. The better resolution is to fix the faulty parent code that failed to perform the wait() properly.

Usually keeping the OS and the application up to par with respect to patches should take care of the problem; however, occasionally you may encounter zombies. It is not critical that they be cleaned up, as they are inactive and generally harmless.

The other technique is to catch the SIGCHLD signal, and have the signal
handler call waitpid() or wait3().

http://www-1.ibm.com/support/docview.wss?uid=swg21085739

http://www.unixguide.net/unix/programming/

No comments: