lkml.org 
[lkml]   [1996]   [May]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
Subjectfork problems (zombie children)
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":

8704 v14 8 0:00 ./forktest
8705 v14 8 0:00 (forktest) Z 8704
8707 v14 8 0:00 (forktest) Z 8704
8708 v14 8 0:00 (forktest) Z 8704
8710 v14 8 0:00 (forktest) Z 8704
8712 v14 8 0:00 (forktest) Z 8704
8714 v14 8 0:00 (forktest) Z 8704
8716 v14 8 0:00 (forktest) Z 8704
8717 v14 8 0:00 (forktest) Z 8704

I ran out of virtual memory on my 32Mb machine on a different app (lynx)
after lots of these were created.



\
 
 \ /
  Last update: 2005-03-22 13:37    [from the cache]
©2003-2014 Jasper Spaans. Advertise on this site