Hi all, I am writing a daemon in perl , where the parent just forks on some requests and the children take over. But I found many child processes becoming defunct. I am not sure why. I am catching SIG_CHLD alright.
To reproduce the problem I have just written a skeleton of my script. The parent process just forks 20 child processes which just sleep and exit after some random seconds. When I run this too I find some defunct processes, the problem is I do not get defunct processes everytime. So this behaviour is not reproducible ( at least with my script :-) ) I am using perl 5.83 on linux ( fedora-3) Can someone help me out avoiding these zombies Thanks Ram ------------------------------------ MY SCRIPT HERE --------- use strict; $GLOBAL::NUM_CH =0; $|=1; $SIG{CHLD}=\&count_ch; foreach(1..20){ unless(fork()){ sleep int(rand(20)); exit 0; } print "No of children running now " . ++$GLOBAL::NUM_CH . "\n"; sleep 2; } foreach (1..100){ print "PARENT CHECK LOOP: No of children running now " . $GLOBAL::NUM_CH . "\n"; exit(0) unless($GLOBAL::NUM_CH); sleep 5; } print "Oops : Something went wrong Not all children have quit\n"; sub count_ch { print "1 CHILD QUIT: No of children running now " . --$GLOBAL::NUM_CH . "\n"; wait(); } --------------------------------- END OF SCRIPT -------- ---------------------------------------------------------- Netcore Solutions Pvt. Ltd. Website: http://www.netcore.co.in Spamtraps: http://cleanmail.netcore.co.in/directory.html ---------------------------------------------------------- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>