[lkml]   [1996]   [May]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: fork problems (zombie children)
Thomas Zerucha <> writes:

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

Exited children stay around in the process table to allow their parent
to get their status using wait(). You should either wait() for your
children or ignore the SIGCHLD signal (using signal(SIGCHLD, SIG_IGN))
to avoid this.

Note that this is a generic UN*X thing, not Linux specific.


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