$SIG{INT} = $SIG{TERM} = $SIG{__DIE__} = \&signal_handler;
sub signal_handler {
unlink($lockfile) if -w $lockfile;
}
Now this works just fine for INT and TERM but adding __DIE__ causes problem since some of the indirectly called modules use "eval" to test for conditions that don't result in a real exit.
Specifically, one of my routines indirectly calls XML::Simple which uses the following "eval" block to test if XML::SAX is available:
eval { require XML::SAX; }; # We didn't need it until now
if($@) { # No XML::SAX - fall back to XML::Parser
if($preferred_parser) { # unless a SAX parser was expressly requested
croak "XMLin() could not load XML::SAX";
}
return($self->build_tree_xml_parser($filename, $string));
}