home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 38.15 Cleaning Up an Unkillable Process Chapter 38
Starting, Stopping, and Killing Processes
Next: 38.17 Automatically Kill Background Processes on Logout in csh
 

38.16 Why You Can't Kill a Zombie

[Processes in your ps output that are in the <exiting> or Z status are called zombies . -JP]

You cannot kill zombies; they are already dead.

"What is a zombie?" I hear you ask. "Why should a dead process stay around?"

Dead processes stick around for two principal reasons. The lesser of these is that they provide a sort of "context" for closing open file descriptors (38.3 ) , and shutting down other resources (memory, swap space, and so forth). This generally happens immediately, and the process remains only for its major purpose: to hold on to its name and exit status (44.7 ) .

A process is named by its process ID or PID. Each process also has associated with it a Parent Process ID . The parent PID is the PID of the process that created it via fork (38.2 ) , or, if that particular process has since vanished, 1 (the PID of init (38.2 ) ). While the original parent is around, it can remember the PIDs of its children. These PIDs cannot be re-used until the parent knows the children are done. The parent can also get a single byte of status (44.7 ) from each child. The wait system call looks for a zombie child, then "collects" it, making its PID available and returning that status. The init (8) program is always waiting, so that once a parent exits, init will collect all its children as they exit, and promptly ignore each status.

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 (42.1 ) close routine, and if it remains that way forever, the driver has a bug.

- CT in comp.unix.questions on Usenet, 16 January 1989


Previous: 38.15 Cleaning Up an Unkillable Process UNIX Power Tools Next: 38.17 Automatically Kill Background Processes on Logout in csh
38.15 Cleaning Up an Unkillable Process Book Index 38.17 Automatically Kill Background Processes on Logout in csh

The UNIX CD Bookshelf NavigationThe UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System