I have a perl script (modified from one of Chris
Nandor's) that I run as a background-process/daemon
via fork(). Now I know I can use kill to end it, but I
was wondering if there was a way that I can catch the
SIGTERM to do one last thing before quitting? It looks
like it should already do this, the relevant code goes
like:
$SIG{CHLD} = 'IGNORE';
my $pid;
if (1) {
$pid = fork;
if ($pid) {
print "Running background process ($pid)\n";
exit;
}
}
END {
&output() unless $pid;
}
... which I interperate as when the parent quits
(exit) nothing happens, but when the child quits
(kill) it should run &output(). This doesn't happen
though. Is there another way?
~wren
(Perl 5.8.3, OSX 10.2.8)
__________________________________
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
http://promotions.yahoo.com/new_mail