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

What you need here is to tell the parent to ignore all signals dealing
with the death of a child process ( not the _best_ thing to do, but works
well )

Do this by doing a:

signal(SIGCHLD,SIG_IGN);

Hope this helps.

PS A good book that explains this plus MUCH more, is
UNIX Network Programing
by W. Richard Stevens
ISBN 0-13-949876-1
Cost: US $59.95

--
James R. Leu
Network Administrator
CORE Digital Communication Services
jleu@coredcs.com


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