[X-Unix] Zombies

David Ledger dledger at ivdcs.demon.co.uk
Sat Jun 19 23:40:00 PDT 2004


>From: "Cloyce D. Spradling" <cloyce+xunix at headgear.org>
>Subject: Re: [X-Unix] Zombies
>Message-ID: <20040616210022.GX320 at monkey.headgear.org>
>
>On Wed, Jun 16, 2004 at 03:20:40PM -0500, Gretchen Hayman wrote:
>: On Jun 14, 2004, at 18:40, James Bucanek wrote:
>: > I don't have any handy way of making a zombie process to test this,
>: Ah, now there's a helpful little script someone could write!  :)
>
>Handy-dandy zombie factory (use at your own risk):
>
>----CUT----OW----CUT----OW----CUT----
>#include <sys/types.h>
>#include <unistd.h>
>
>#define ZOMBIES 2
>int main() {
>   int i;
>
>   for(i = 0; i < ZOMBIES; i++) {
>     if (fork() == 0) {
>       /* child */
>       exit(0);
>     }
>   }
>   /* if you just exit here, init will reap the zombies */
>   sleep(10000);
>}
>----CUT----OW----CUT----OW----CUT----

 From what I remember from many years ago, what *should* happen is 
that when each child exits, it sends a death_of_child signal to the 
parent.  Here the parent exits without checking, but the 'exit' 
routine *should* check for signals and perform the 'wait' on each 
child.  'exit' is not a simple 'program-ends-here', but  a drop-back 
to the outer code that each program is wrapped in to make it part of 
a process.  Also 'init' should check for signals from every orphan it 
inherits, so a zombie with a parent of init *should* be impossible.

I havn't tried it, but Cloyce says the above produces zombies.  That 
indicates a deficiency in OSX/Darwin as compared to other Unix 
systems; certainly when compared to Bsd4.1 when I learned this stuff.

David


-- 
David Ledger - Freelance Unix Sysadmin in the UK.
Chair of HPUX SysAdmin SIG of hpUG technical user group (www.hpug.org.uk)
dledger at ivdcs.co.uk (also dledger at ivdcs.demon.co.uk)
www.ivdcs.co.uk



More information about the X-Unix mailing list