in reply to Re: How to catch 'die' signal - CONVERSE case of #811295
in thread How to catch 'die' signal - CONVERSE case of #811295

Thanks to the two previous posters for suggesting an END block. As a long-time perl dilettance, I was not aware of such usage.

I then noticed though that END block doesn't capture things like SIGINT/SIGTERM.

To capture those, I had to add the following line of code:
$SIG{INT} = $SIG{TERM} = $SIG{HUP} = sub { exit; };
Is this the correct way to do it?

Replies are listed 'Best First'.
Re^3: How to catch 'die' signal - CONVERSE case of #811295
by ikegami (Patriarch) on Dec 07, 2009 at 04:53 UTC
    By default, the OS unloads the program in response to those signals. That looks like a good solution to me.