in reply to Re^2: Custom SIG DIE handler that isn't executed in evals
in thread Custom SIG DIE handler that isn't executed in evals

But what to do when the eval is deep within a bunch of system modules? I'm receiving e-mails right now from my script because of an eval located in /usr/local/lib64/perl5/XSLoader.pm
  • Comment on Re^3: Custom SIG DIE handler that isn't executed in evals

Replies are listed 'Best First'.
Re^4: Custom SIG DIE handler that isn't executed in evals
by Anonymous Monk on Sep 14, 2016 at 04:35 UTC

    But what to do when the eval is deep within a bunch of system modules?

    see perlvar#$^S

Re^4: Custom SIG DIE handler that isn't executed in evals
by RonW (Parson) on Sep 14, 2016 at 18:51 UTC

    Expanding on what the anony monk said, your die handler can test if the die happened in an eval.

    So, maybe the following:

    # not tested sub SigDieHandler { unless ($^S) # skip if die happened in an eval { ...; # create and send email } }

    Not tested, YMMV.