Re: fork problems (zombie children)

Ronald Wahl (Ronald.Wahl@informatik.tu-chemnitz.de)
Wed, 8 May 1996 14:08:38 +0200 (MET DST)


On Mon, 6 May 1996, Thomas Zerucha wrote:

> What am I doing wrong? The following program:
>
> #include <signal.h>
> #include <sys/wait.h>
> main(){
> for(;;) {
> if( !fork() ) {
> exit(0); /* child, exit immediately */
> }
> sleep(1);
> }
> }
>
> when run with PID=8704 creates children that stay undead until the parent
> process terminates, e.g. from "ps -x":

If a process terminates a SIGCHLD is send to the parent process which has
to catch this signal and and call wait or waitpid to read its exit status.
After this the process is removed from the queue in the kernel.

ron

--
\ Ronald Wahl --- rwa@informatik.tu-chemnitz.de   \
 \ WWW: http://www.tu-chemnitz.de/~row             \
  \ PGP key available by finger to my email address \