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

Hi All,
  Following the post here:
51097
I have implemented a global die signal handler. I have the:
die @_ if $^S;
to drop out if this die is generated within an eval block, but my issue is that the eval block is dying within it's compile time.
    As per perldoc: "$^S Current state of the interpreter. Undefined if parsing of the current module/eval is not finished (may happen in $SIG{__DIE__} and $SIG{__WARN__} handlers). True if inside an eval, otherwise false.".
  So $^S is undef, but the die is within an eval block. What is the best way to deal with this? I'm about to write code that check the stack trace for "eval {...}" and drop out if it's found. But that doesn't seem like the idea solution?

Lyle

Replies are listed 'Best First'.
Re: SIGDIE problem at eval compile time
by anonymized user 468275 (Curate) on Apr 15, 2011 at 11:04 UTC
    $ perl -e 'eval{die @_ if $^S;}' did not die, (albeit v 5.8.8 I used for the test). I think it's enough reason to ask to see the rest of the code.

    One world, one people

      Or did it? It's like asking whether a falling tree in a forest makes a sound if noone hears it.

      If you change the code to see whether it actually dies, it does:

      $ perl -e 'eval{die @_ if $^S; 1} or print "$@"' Died at -e line 1.
      Now, since the die is inside an eval, the die doesn't cause the program to terminate.