Open
Description
Description
If you register a subroutine as a $SIG{__DIE__}
handler, then call it normally, and that sub then (directly or indirectly) throws an exception, the $SIG{__DIE__}
behavior doesn't kick in; i.e. the sub is not re-invoked to handle the exception.
Steps to Reproduce
$ perl -we 'my $x = 0; sub foo { print "foo()\n"; die $x++ } $SIG{__DIE__} = \&foo; foo'
foo()
0 at -e line 1.
(Note that $SIG{__DIE__}
has no effect here.)
Expected behavior
$ perl -we 'my $x = 0; sub foo { print "foo()\n"; die $x++ } $SIG{__DIE__} = \&foo; foo'
foo()
foo()
1 at -e line 1.
There should be exactly two calls to foo: One from foo
in the main code, the other via $SIG{__DIE__}
. It should not recurse further because as perldoc -v %SIG
explains:
The
__DIE__
handler is explicitly disabled during the call, so that you can die from a__DIE__
handler.
Metadata
Assignees
Labels
No labels