The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.


Signal::StackTrace - install signal handler to print a stacktrace.


    # default installs the handler on USR1
    # these have the same result.

    use Signal::Stacktrace;
    use Signal::Stacktrace qw( USR1 );

    # install the handler on any valid signals

    use Signal::Stacktrace qw( HUP );
    use Signal::Stacktrace qw( HUP USR1 USR2 );

    # this will fail: FOOBAR is not a valid
    # signal (on any system I know of at least).

    use Signal::Stacktrace qw( FOOBAR );


This will print a stack trace to STDERR -- similar to the sigtrap module but without the core dump using simpler syntax.

The module arguemts are signals on which to print the stack trace. For normally-terminating signals (e.g., TERM, QUIT) it is proably a bad idea in production environments but would be handy for tracking down errors; for non-trapable signals (e.g., KILL) this won't do anything.

The import will croak on signal names unknown to ( see $Config{ sig_name } ).

The stack trace looks something like:

  Caller level 1:
    Bitmask => '',
    Evaltext => undef,
    Filename => '(eval 9)[/usr/lib/perl5/site_perl/5.8.8/i686-linux/Term/]',
    Hasargs => 0,
    Hints => 0,
    'Line-No' => 7,
    Package => 'Term::ReadKey',
    Require => undef,
    Subroutine => '(eval)',
    Wantarray => 0


  Caller level 8:
    Bitmask => '',
    Evaltext => undef,
    Filename => '-e',
    Hasargs => 0,
    Hints => 0,
    'Line-No' => 1,
    Package => 'main',
    Require => undef,
    Subroutine => 'DB::DB',
    Wantarray => 1

  End of trace


None, yet.



Dealing with signals in perl.


Trapping signals with supplied handlers, getting core dumps.


$Config{ sig_name } gives the valid signal names.


Steven Lembark <>


This code is licensed under the same terms as Perl 5.8 or any later version of perl at the users preference.