Re: zombie processes

From: Mike Simons (msimons@fsimons01.erols.com)
Date: Wed Jun 23 1999 - 23:28:54 PDT


Mike Machado wrote:
>a snake got into a PG&E power box down the street and took
>out power for 6 ours and our UPS could not hold out that long :)

  No backup generator?

Brian E. Lavender wrote:
>I noticed when I run top I have two zombie processes. How do I get
>rid of them without rebooting?

[...I hope this makes sense to someone...]

  Okay the deal on zombie processes they are already dead, can not be killed,
and are not a problem (unless you have a few hundred). They only get
created by poorly written code when a program calls fork(2) and the
child process exits but the parent doesn't do the right thing. From the
time the child exits until the parent calls wait there is a "zombie"
process... which holds the return code and stuff from the child.

The parent should do one of two things:
  - when kernel sends the parent a signal (SIGCHLD) saying a child's
    exit status is ready to wait(2) for, the parent calls should call wait.
  - say with sigaction(2) that it doesn't care about the return status
  of any of it's children so when they exit the kernel wipes up after
  the zombie processes automatically (*).

  Older Unix's could easily be wiped out by a few zombies because it
saved all memory associated with a exited child process (zombie)
until it was reaped by a wait call.

  So there is a program that is launching child processes and is not
properly cleaning up after them. One of several correct ways to deal
with this:
  - fix the misbehaving program
  - stop using the misbehaving program
  - complain to the authors about the misbehaving program
  - exit the misbehaving program periodically

  You can figure out which program is spawning these zombie processes
with a pstree or some such. ... Shame it's KDE huh? ;)

    TTFN,
      Mike Simons

* - the "parent process" of any child and zombie change to process id 1
    (init) when the real parent exits. Init periodically calls wait
    to reap random zombie processes on the system.



This archive was generated by hypermail 2b29 : Fri Feb 25 2000 - 14:29:09 PST