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



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