I've been playing around with SGI::FAM.pm for the last few days for a project of mine. I've decided that I want to fork off subprocesses of my main program to deal with the files that SGI::FAM reports.
This is all works great when I set:
$SIG{CHLD} = IGNORE;
but when I set:
$SIG{CHLD} = \&reap_the_children;
sub reap_the_children {
my $child;
while (($child = waitpid(-1, &WNOHANG)) > 0) {
my $file = $seen{$child};
print "Deleting $file from seen hash\n";
print "Deleting $child from seen hash\n";
delete $seen{$file};
delete $seen{$child};
}
$SIG{CHLD} = \&reap_the_children;
}
Here is my output:
Forking child from 18263 (parent process)
Forked 19241 (child process)
19241:pureftpd.vevo3w (child does stuff here and then exits)
Deleting pureftpd.vevo3w from seen hash (cleanup here)
Deleting 19241 from seen hash (cleanup here)
SGI::FAM: No child processes at ./watcher.pl line 30 (program dies here)
When I set $SIG{CHLD} to ignore, the program runs indefinitely doing what it does. I really think I need the ability to do some extra things in the reaping of the children, but it seems to be interfering with the normal operation of SGI::FAM.pm.
Can anyone help??
Thanks alot.