puterboy has asked for the wisdom of the Perl Monks concerning the following question:
The problem is that my new handler catches the error caused by non-existent XML/Sax.pm (i.e., "Can't locate XML/SAX.pm in @INC...) and removes the lock file even though the eval block protects it from actually exiting.$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 pr +oblem since some of the indirectly called modules use "eval" to test +for conditions that don't result in a real exit.<br><br> Specifically, one of my routines indirectly calls XML::Simple which us +es the following "eval" block to test if XML::SAX is available: <code> eval { require XML::SAX; }; # We didn't need it until now if($@) { # No XML::SAX - fall back to XML::P +arser 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)); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to catch 'die' signal - CONVERSE case of #811295
by ikegami (Patriarch) on Dec 06, 2009 at 20:28 UTC | |
by puterboy (Scribe) on Dec 07, 2009 at 03:17 UTC | |
by ikegami (Patriarch) on Dec 07, 2009 at 04:53 UTC | |
|
Re: How to catch 'die' signal - CONVERSE case of #811295
by Corion (Patriarch) on Dec 06, 2009 at 19:27 UTC | |
|
Re: How to catch 'die' signal - CONVERSE case of #811295
by keszler (Priest) on Dec 06, 2009 at 21:24 UTC |