in reply to Custom SIG DIE handler that isn't executed in evals
I suggest reverting the sig die handler before the eval, then restore it, after.
Maybe something like this:
# untested my $defaultSigDie = $SIG{__DIE__}; $SIG{__DIE__} = \&SigDieHandler; sub doEval { my $savedHandler = $SIG{__DIE__}; $SIG{__DIE__} = $defaultSigDie; my $result = eval $_[0]; $SIG{__DIE__} = $savedHandler; return $result; }
Untested. YMMV
Update: Forgot about local (Thanks, anony monk)
# untested my $defaultSigDie = $SIG{__DIE__}; $SIG{__DIE__} = \&SigDieHandler; sub doEval { local $SIG{__DIE__} = $defaultSigDie; my $result = eval $_[0]; return $result; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Custom SIG DIE handler that isn't executed in evals
by Anonymous Monk on Sep 14, 2016 at 02:02 UTC | |
by tunafish (Beadle) on Sep 14, 2016 at 04:14 UTC | |
by Anonymous Monk on Sep 14, 2016 at 04:35 UTC | |
by RonW (Parson) on Sep 14, 2016 at 18:51 UTC |