Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
/perl5Public

$SIG{__DIE__} handler doesn't work when called explicitly #22984

Closed
@mauke

Description

@mauke

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 fromfoo in the main code, the other via$SIG{__DIE__}. It should not recurse further because asperldoc -v %SIG explains:

The__DIE__ handler is explicitly disabled during the call, so that you can die from a__DIE__ handler.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp