Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

catch kill -9 from unix command prompt

6 views
Skip to first unread message

Ken Lehman

unread,
Dec 17, 2002, 11:51:36 AM12/17/02
to begi...@perl.org
Is there a way for my program to execute a few lines of code before dying
when it is sent a kill -9 from a unix shell? The book I have says no, I
don't want to ignore the signal, just some clean up.
Thanks.
-Ken

----------------------------------------------------------------------------
--------------------
The views and opinions expressed in this email message are the sender's
own, and do not necessarily represent the views and opinions of Summit
Systems Inc.

Jensen Kenneth B Sra Afpc/Dpdmpq

unread,
Dec 17, 2002, 12:00:30 PM12/17/02
to Ken Lehman, begi...@perl.org
use sigtrap 'handler' => &sig_handler, KILL;

&sig_handler{
#your clean up code you want executed
}

sigtrap can be found on cpan, there are more ways to use it... Documented
there.


SrA Jensen


--
To unsubscribe, e-mail: beginners-...@perl.org
For additional commands, e-mail: beginne...@perl.org

Bob Showalter

unread,
Dec 17, 2002, 12:10:08 PM12/17/02
to Ken Lehman, begi...@perl.org
> -----Original Message-----
> From: Ken Lehman [mailto:ken_l...@summithq.com]
> Sent: Tuesday, December 17, 2002 11:52 AM
> To: 'begi...@perl.org'
> Subject: catch kill -9 from unix command prompt
>
>
> Is there a way for my program to execute a few lines of code
> before dying
> when it is sent a kill -9 from a unix shell? The book I have
> says no, I
> don't want to ignore the signal, just some clean up.
> Thanks.

No. SIGKILL cannot be caught. If it could, you could prevent the sysadmin
from terminating your process.

SIGKILL is not designed for gracefully terminating. Use SIGTERM and/or
SIGINT for that, both of which can be caught.

0 new messages