Archive for July 24th, 2007

Zombies

Zombies are processes that have terminated, but have not been able to return their ending status to any parent. A zombie does not occupy any resources except a single process table entry. There is no code in memory, no data, no file descriptors, no pipes, no ports - nothing.

This happens because the parent (the spawning process) did not handle the child’s return properly - that is, it did not handle the SIGCHLD (or SIGCLD) signal properly. When such a parent finishes, then the process becomes a child of the init process (process ID #1). It is then expected that /bin/init will reap the process (cull the return status) using a wait() call.

However, sometimes init will not reap zombies, or the parents remain running and never reap. What’s worse, this handling of process children varies from operating system to operating system, so proper handling is often not portable. Handling spawned processes requires proper handling of the SIGCHLD signal, with the proper wait() commands.

One recommendation is thus: institute a SIGCHLD handler which will continue to wait for processes (using wait()) until there are no more processes. The (almost) pseudocode for such a handler would be:

handleCHLD {
while (deadProcessesExist)
continue;
}

It may be possible to kill off a zombie by sending a SIGCHLD to the parent process, but again this is not portable and only works on some System V derived systems. To do this, execute the command

kill -17 ppid

This sends a SIGCHLD signal to the parent process, given the proper process id (ppid) to send it to.

Further resources:

Zombies(5) from System V manpages
UNIX FAQ Question 3.13: How do I get rid of zombie processes that persevere?
Delve into UNIX Process Creation


Add comment 24 July 2007


David Douthitt

David is an experienced UNIX and Linux system administrator, a former Linux distribution maintainer, and author of two books ("Advanced Topics in System Administration" and "GNU Screen: A Comprehensive Manual"). View David Douthitt's profile on LinkedIn

Recent Posts

Top Posts

RSS Sharky's Column!

Calendar

July 2007
M T W T F S S
« Jun   Aug »
 1
2345678
9101112131415
16171819202122
23242526272829
3031  

Recent Comments

bharat on The Demise of the HP-UX System…
H4mm3r on Avoiding catastrophe!
Vladimir on Argument list too long?
ddouthitt on The UNIX find command and…
Mihir G joshi on The UNIX find command and…

Category Cloud

BSD Career Debian Debugging Fedora FreeBSD HPUX Learning Linux MacOS X Mind Hacks Mobile Computing NetBSD Networking OpenBSD OpenSolaris Open Source OpenVMS Personal Notes Portable Presentations Red Hat Scripting Security Solaris Tips Ubuntu UNIX Wheel Group Windows

Archives

Feeds

Links