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.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.