> >The SIG{CHLD} handler doesn't get called since the output from > >> print LOG "Child process no. $stiff exited with status $?\n"; >> >is missing. >
You can't see the output in your log is because when your childs are executing,your parent has exited. In order to see the callbacking childs,just add this line in the code end: sleep while(1); # parent sleep to wait for childs exiting And,don't forget to flush the LOG file handle. I'v modified your code as below,it could show me correctly the childs exiting status from the log. use strict; use warnings; use POSIX qw(WNOHANG); $SIG{CHLD} = \&reaper; open LOG, ">>","test.log" or die "Can't open log file: $!"; select LOG;$|=1;select STDOUT; # here is important sub reaper { while((my $stiff = waitpid(-1, WNOHANG)) > 0) { print LOG "Child process no. $stiff exited with status $?\n"; } } my $dir = "."; my @files; opendir DH, $dir or die "Can't open Video dir: $!"; for (readdir DH) { (/msfwsvr\.log\./)? push @files, $_ : next; } closedir DH; print LOG "Simpsons episodes:\n", map "$_\n", @files; for my $file(@files) { defined(my $pid = fork) or die "Can't fork for $file: $!"; unless($pid) { exec "sleep 5"; die "Can't execute tovid for process no $$ on file $file: $!"; } else { print LOG "Forked child process no. $pid for file $file.\n"; } } sleep while(1); HTH. -- Jeff Pang NetEase AntiSpam Team http://corp.netease.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>