Re: fork problems (zombie children)

Aaron Ucko (UCKO@vax1.rockhurst.edu)
Wed, 08 May 1996 16:49:27 -0600 (CST)


>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);
> }
>}

You aren't wait()ing for your children after they exit.

-- Aaron Ucko (ucko@vax1.rockhurst.edu; finger for PGP public key) | httyp!
"That's right," he said. "We're philosophers. We think, therefore we am."
-- Terry Pratchett, _Small Gods_ | Geek Code 3.1 [for explanation, finger
hayden@mankato.msus.edu]: GCS/M/S/C d- s: a18 C++(+++)>++++ UL++>++++ P++
L++>+++++ E- W(-) N++(+) o+ K- w--- O M@ V-(--) PS++(+++) PE- Y(+) PGP(+) t(+)
!5 X-- R(-) tv-@ b++(+++) DI+ !D-- G++(+++) e->+++++(*) h!>+ r-(--)>+++ y?