http://www.perlmonks.org?node_id=379922

Marcello has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

My Perl server runs 24/7. Whenever the program is stopped, it needs to delete the database record it created on startup so everything is in sync. This is done in the END block. This line will make sure the END block is executed whenever such a signal is received (I know, I could also 'IGNORE' them):

$SIG{TERM} = $SIG{INT} = $SIG{QUIT} = $SIG{HUP} = sub { die; };
Questions:
  • What signal is sent to a process when the machine is restarted (KILL?)
  • Does the KILL signal cause the END block to be executed (since it cannot be caught)?
  • Is it 100% sure the END block is executed using the above code or might there be other situations in which this fails?

    I'm trying to prevent my server from exiting without execution of the END block.

    Thanks for any input

    Update: I'm on Redhat Linux