Reaping zombie processes

David.J.Ferbrache mcvax!cs.hw.ac.uk!davidf at uunet.uu.net
Sat Mar 4 07:21:49 AEST 1989


root%helios.UCSC.EDU at ucscc.ucsc.edu (De Clarke (Systems Mgr)):
> 1) Has anyone managed to kill off user processes that go <exiting>?  Mine
> hang about for anywhere from a day to three days before they finally drop
> off.  Since they do drop off in the end (I guess the lbolt that they're
> waiting on finally hits) there must be a way to force them out by making
> the lbolt arrive sooner, right?  I asked Sun and they said basically
> "reboot."  (Great answer >: -( ) So thought I'd ask the public.

As far as I know (as the moderator said) there is no safe way of
terminating such a process, there is however a slightly dodgy (it involves
manipulation of the kernel proc structures) method.

Basically the method involves running a program (called reaper on our
systems) which scans the process table for zombie entries (examining the
stat field in the process structure entry for SZOMB states).

When a zombie process is found the program rewrites the process structure
for that process modifying the PPID field to contain the process id of the
reaper program. The reaper program can then wait on its newly adopted
child process which should affect an orderly clean up of process
resources.

This method works in BSD 4.2 releases which do not contain the rewritten
process table code. The new process table code replaces a search for
processes based on a hash of the pid, with no explicit structuring of
child-parent relations excepting the ppid field, with a tree structure of
pointers lacing together the child and parent processes. In such a more
complex environment rewritting the pointer fields is potentially far more
dangerous.

The reaper program (which runs on Sun 3 os 3.5, Orion HLH and BSD 4.2)
seems to work for all processes which are actually in the zombie state,
but not for processes which are blocked waiting on a close of a file in
the _exit routines.

Anyway, if anybody is remotely interested I will mail them the source.

Dave Ferbrache                            Personal mail to:
Dept of computer science                  Internet <davidf at cs.hw.ac.uk>
Heriot-Watt University                    Janet    <davidf at uk.ac.hw.cs>
79 Grassmarket                            UUCP     ..!mcvax!hwcs!davidf 
Edinburgh,UK. EH1 2HJ                     Tel      (UK) 031-225-6465 ext 553



More information about the Comp.sys.sun mailing list