lkml.org 
[lkml]   [1996]   [May]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: fork problems (zombie children)
   Date: 	Mon, 6 May 1996 18:22:11 -0500 (CDT)
From: Thomas Zerucha <tz@execpc.com>

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":

You need to wait() on the children (from the parent) to reap them.
Otherwise they stay around so that the parent can grab their exit
status.


\
 
 \ /
  Last update: 2005-03-22 13:37    [W:0.225 / U:0.280 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site