*BSD News Article 57391


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.anu.edu.au!harbinger.cc.monash.edu.au!news.mel.connect.com.au!munnari.OZ.AU!spool.mu.edu!howland.reston.ans.net!swrinde!newsfeed.internetmci.com!news.fyionline.com!op.net!candle.pha.pa.us!not-for-mail
From: root@candle.pha.pa.us (Bruce Momjian)
Newsgroups: comp.unix.bsd.misc,comp.unix.bsd.bsdi.misc
Subject: Re: BSD 4.4:  Preventing zombies SIGCHLD
Followup-To: comp.unix.bsd.misc,comp.unix.bsd.bsdi.misc
Date: 20 Dec 1995 03:32:56 GMT
Organization: a consultant's basement
Lines: 41
Message-ID: <4b8058$8gc@picasso.op.net>
References: <4b47nt$e1a@picasso.op.net> <4b6een$667@noao.edu> <4b78mk$1t5@park.uvsc.edu>
NNTP-Posting-Host: s1-03.ppp.op.net
X-Newsreader: TIN [UNIX 1.3 950726BETA PL0]
Xref: euryale.cc.adfa.oz.au comp.unix.bsd.misc:387 comp.unix.bsd.bsdi.misc:1740

Terry Lambert (terry@lambert.org) wrote:
: rstevens@noao.edu (W. Richard Stevens) wrote:
: ]
: ] > I am looking for a standard way of automatically preventing zombies by
: ] > auto-reaping exit'ed children.
: ] > I know SIGCLD works under System V, and I know I can install a SIGCHLD
: ] > handler to wait() after each child exit.
: ] 
: ] The POSIX solution is to call waitpid() from a SIGCHLD handler, but you
: ] must call it in a loop with the WNOHANG option to avoid leaving any
: ] zombies around.  Calling wait() can still leave zombies if multiple
: ] children exit() at about the same time.  Here is what it takes:
: 
: Not to contradict another Tucson resident, but I thought that
: ignoring the signal would cause it to be automatically reaped
: on exit?

I believe this is true, but I thought that the process was a zombie
until the parent exits.

I am embarased to say I asked this question because I am hacking acm
(the PD X F-16/Mig flight simulator) to use sox (the PD unix sound
generator) to generated flight sounds rather than use NETAUDIO or
HPAUDIO, which I don't have.  (I will send the patches to the author.)

Each time I want a sound, I vfork() and exec() a script that runs sox on
the sound file.  Without a child reaper, each sound generates a zombie,
and depending on how long you can stay in the air, that could be lots of
them.

I am somewhat embarased to have involved W. Richard Stevens and Terry
Lambert in such a trivial project, but hey, its a fun game.  

I love to watch the plane fly as I type.  Have I been working on
computers too long?:-)

-- 
Bruce Momjian                          |  830 Blythe Avenue
root@candle.pha.pa.us                  |  Drexel Hill, Pennsylvania 19026 
  +  If your life is a hard drive,     |  (610) 353-9879(w) 
  +  Christ can be your backup.        |  (610) 853-3000(h)