[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Problems with the undead (zombies)

On Sun, 7 Jun 1998 sjc@gis.net wrote:

> > To fix your zombie problem you should IGNORE sigchld or arrange for wait
> > to be called (but not in the signal handler)
> ahh not call wait() in the signal handler...I was just now about to tackle 
> this problem...hmm unfortunatly im not sure where other than the signal 
> handler to call wait...hmm
> maybe ignore is better solution..ill try it 

More incentive to do it in a signal handler, tested code:
void sig_handler (int i) {
  if (i == SIGCHLD) { /* signal based reaper */
    while (wait3(NULL, WNOHANG, 0) > 0);

Placing a wait someone else may cause your program to hang until a child
dies.  But note that if you have a select or some other kernel call, you
will exit from that call with some kind of error code (it took me a while
to realize this, never stopped using perror since then).

> ok...according to my book it is ignored by default? I don't understand
> why these zombies are made then?
> maybe I will just add a wait to main loop so it will just perform cleanup
> eveytime a new connection is made?

You can get info back from your child from the wait or somewhere.  So the
kernel keeps your undead child around until you run the wait or die
yourself.  When you die, apparently init, the parent of all, will get rid
of the zombies.


Brandon Mitchell <bhmit1@mail.wm.edu>   "We all know linux is great... it
PGP: finger -l bhmit1@cs.wm.edu          does infinite loops in 5 seconds"
Phone: (757) 596-5550                      --Linus Torvalds
Debian Testing Group status: http://bhmit1.home.ml.org/deb/

To UNSUBSCRIBE, email to debian-devel-request@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org

Reply to: