Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 31 Oct 1996 10:17:39 -0500 (EST)
From:      Rick Weldon <rick@wisetech.com>
To:        Rodrigo Ormonde <ormonde@trem.cnt.org.br>
Cc:        hackers@freebsd.org
Subject:   Re: Zombie processes
Message-ID:  <Pine.BSF.3.91.961031101149.27432A-100000@badboy.wisetech.com>
In-Reply-To: <9610311301.AA11007@trem.cnt.org.br>

next in thread | previous in thread | raw e-mail | index | archive | help

On Thu, 31 Oct 1996, Rodrigo Ormonde wrote:
>   Everything is working fine, except for the fact that when the child
> processes exit they become zombies. Every time a new connection is 
established
> and finished there is a new zombie process. I can't execute a wait() on the
> parent process because it has to listen to new connections and can't be 
block$
> on the wait() call.
>   Is there any way to remove the zombie process from the system without
> blocking the parent process ?
 
You have to tell the parent to ignore the kids. I 
got this straight from Stevens Network Programming page 70 something.


Here is a sig handler

/* ignore the kids, BSD requires that we define a func to call on SIGCHLD */
sig_child()
{
   
  int pid;
  int status;
   
   while( (pid=wait3(&status,(int)WNOHANG, (struct rusage *) 0)) > 0);
   
}  


Then just install the handler in main in the parent:


 signal(SIGCHLD,(sig_t) sig_child);

The children are ignored and the parent drives on.

Rick


| Rick Weldon -- WISE-Tech LLC
| E-mail: rick@wisetech.com




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.3.91.961031101149.27432A-100000>