[ale] kill a zombie process

Bob bob at cavu.com
Fri Oct 22 15:03:03 EDT 1999


> When I run top, I have a zombie process (it's a cron job that does my
> nightly backup) running and I need to kill it.  I have tried kill -9
> <pid #>, but it doesn't work.  Any ideas?  Thanx.

You cannot kill it because it already is dead.  That is why it is called
a zombie. ;^)

To be technical, a zombie process is one that already has terminated via
an exit() system call or uncaught signal.  In order for it to "go away"
(be removed from the process table, its parent must do a wait() system call
or one of its variants.

The ultrasecret reason for this is that the zombie contains some statistics
on the process such as the exit status (why it died) and CPU time used that
must be returned to the parent and this is stored in -- guese where --
the zombie's per-process structure.  This is why it cannot be removed until
the parent does a wait() on it.

Sometimes a parent fails to do the wait(), usually due to a programming
bug.  Any old C program can do a fork() and not do the wait() and cause this.
It used to be a problem with shell scripts doing "foo&" and never waiting back
in the dark days of older UNIX systems.


In your case, perhaps cron has gotten confused (bug) and lost track of its
children so it is not correctly waiting for them to complete.

As the other poster suggested, restarting cron will start it thusly:

        /etc/rc.d/init.d/crond stop
        sleep 1
        /etc/rc.d/init.d/crond start

should do it.  This works because if a process dies (e.g. crond) then
init (process 1) inherits its children and init will do the wait correctly.

Bob Toxen
bob at cavu.com http://www.cavu.com
transam at cavu.com [ALE & Linux Laptops]
Fly-By-Day Consulting, Inc.

"The bad reputation UNIX has gotten is totally undeserved, laid on by
people who don't understand, who have not gotten in there and tried
Anything."  -- Jim Joyce, owner of Jim Joyce's UNIX Bookstore






More information about the Ale mailing list