--- Neil Bowers <[EMAIL PROTECTED]> wrote: > You just need to install a TERM handler routine in > the child process.
--- Jerry LeVan <[EMAIL PROTECTED]> wrote: > See http://homepage.mac.com/levanj/LinkSys and grab > linksys.pl. Ah thanks. In my foolishness I didn't think to RTFM (perlipc). Having read it now (and tested the suggested code), I still have a question. So we have a really basic program: a "fork loop", &cleanup, and an END block. If I set $SIG{'TERM'} to \&cleanup in the loop we get the END block when the parent exits, and then when we kill the child we get &cleanup and then END again. So far so good. Now if we take that same simple program and either don't define $SIG{'TERM'} or set it to 'DEFAULT' we get END when the parent dies, but when we kill the child &cleanup isn't run (duh) but neither is END. Is that standard behaviour? I would've thought it'd try to do END if at all possible to clean up after itself. ~wren #!/usr/local/bin/perl if (1) { $pid = fork; if ($pid) { print "Running background process ($pid)\n"; exit; } else { $SIG{'TERM'} = \&cleanup; while (1) {} } } sub cleanup { print "foo\n"; exit 0; } END { print "bar\n"; } __END__ __________________________________ Do you Yahoo!? Yahoo! Mail - 50x more storage than other providers! http://promotions.yahoo.com/new_mail