See http://homepage.mac.com/levanj/LinkSys and grab
linksys.pl.

It has a trap handler prints a message to a log file
closes the log file and then exits. (it does some
other interesting stuff if you have a linksys router :)


Jerry On Aug 19, 2004, at 3:49 PM, wren argetlahm wrote:

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




Reply via email to