The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Signal::StackTrace::CarpLike - install signal handler to print a Carp-like stacktrace

SYNOPSIS

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

use Signal::StackTrace::CarpLike;
use Signal::StackTrace::CarpLike qw( USR1 );

# install the handler on any valid signals

use Signal::StackTrace::CarpLike qw( HUP );
use Signal::StackTrace::CarpLike qw( HUP USR1 USR2 );

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

use Signal::StackTrace::CarpLike qw( FOOBAR );

# use it from the command line
perl -MSignal::StackTrace::CarpLike=INT hanging-test.t

DESCRIPTION

This module is a fork of Signal::StackTrace, which has a uselessly verbose output format. But its interface is perfect, hence this module, which just uses "cluck" in Carp.

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 Config.pm ( see $Config{ sig_name } ).

The stack trace looks something like:

INT at /Users/sartak/.perl/perls/perl-5.12.3/lib/5.12.3/perl5db.pl line 3749
        eval {...} called at /Users/sartak/.perl/perls/perl-5.12.3/lib/5.12.3/perl5db.pl line 3749
        Term::ReadLine::Gnu::AU::__ANON__[/Users/sartak/.perl/perls/perl-5.12.3/lib/site_perl/5.12.3/darwin-2level/Term/ReadLine/Gnu.pm:719]('Term::ReadLine=HASH(0x10099a6e0)', '\x{1}\x{1b}[4m\x{2}  DB<1> \x{1}\x{1b}[24m\x{2}') called at /Users/sartak/.perl/perls/perl-5.12.3/lib/site_perl/5.12.3/darwin-2level/Term/ReadLine/Gnu.pm line 331
        Term::ReadLine::Gnu::readline('Term::ReadLine=HASH(0x10099a6e0)', '  DB<1> ') called at /Users/sartak/.perl/perls/perl-5.12.3/lib/5.12.3/perl5db.pl line 6494
        DB::readline('  DB<1> ') called at /Users/sartak/.perl/perls/perl-5.12.3/lib/5.12.3/perl5db.pl line 2241
        DB::DB called at -e line 1
at /Users/sartak/.perl/perls/perl-5.12.3/lib/5.12.3/perl5db.pl line 3749
        eval {...} called at /Users/sartak/.perl/perls/perl-5.12.3/lib/5.12.3/perl5db.pl line 3749
        Term::ReadLine::Gnu::AU::__ANON__[/Users/sartak/.perl/perls/perl-5.12.3/lib/site_perl/5.12.3/darwin-2level/Term/ReadLine/Gnu.pm:719]('Term::ReadLine=HASH(0x10099a6e0)', '\x{1}\x{1b}[4m\x{2}  DB<1> \x{1}\x{1b}[24m\x{2}') called at /Users/sartak/.perl/perls/perl-5.12.3/lib/site_perl/5.12.3/darwin-2level/Term/ReadLine/Gnu.pm line 331
        Term::ReadLine::Gnu::readline('Term::ReadLine=HASH(0x10099a6e0)', '  DB<1> ') called at /Users/sartak/.perl/perls/perl-5.12.3/lib/5.12.3/perl5db.pl line 6494
        DB::readline('  DB<1> ') called at /Users/sartak/.perl/perls/perl-5.12.3/lib/5.12.3/perl5db.pl line 2241
        DB::DB called at -e line 1

KNOWN BUGS

None, yet.

SEE ALSO

perlipc

Dealing with signals in perl.

sigtrap

Trapping signals with supplied handlers, getting core dumps.

Config

$Config{ sig_name } gives the valid signal names.

AUTHOR

Shawn M Moore <sartak@gmail.com>

ORIGINAL AUTHOR

Steven Lembark <lembark@wrkhors.com> was the original author of Signal::StackTrace from which this module was forked.

LICENSE

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