File Coverage

blib/lib/Signal/StackTrace/CarpLike.pm
Criterion Covered Total %
statement 19 23 82.6
branch 1 4 25.0
condition n/a
subroutine 6 6 100.0
pod n/a
total 26 33 78.7


line stmt bran cond sub pod time code
1             ########################################################################
2             # Signal::StackTrace::CarpLike - run a stack dump on a signal.
3             ########################################################################
4             ########################################################################
5             # housekeeping
6             ########################################################################
7              
8             package Signal::StackTrace::CarpLike;
9              
10 1     1   1105 use 5.006;
  1         5  
  1         37  
11              
12 1     1   5 use strict;
  1         3  
  1         32  
13              
14 1     1   14 use Carp;
  1         2  
  1         73  
15 1     1   5 use Config;
  1         2  
  1         37  
16              
17 1     1   16427 use Data::Dumper;
  1         8072  
  1         281  
18              
19             ########################################################################
20             # package variables
21             ########################################################################
22              
23             our $VERSION = 0.01;
24              
25             my %known_sigz = ();
26              
27             @known_sigz{ split ' ', $Config{ sig_name } } = ();
28              
29             ########################################################################
30             # install the signal handlers
31             ########################################################################
32              
33             sub import
34             {
35             # discard this package;
36             # remainder of the stack are signal names.
37              
38 1     1   15 shift;
39              
40 1 50       5 if( @_ )
41             {
42 0 0       0 if( my @junk = grep { ! exists $known_sigz{ $_ } } @_ )
  0         0  
43             {
44 0         0 croak "Unknown signals: unknown signals @junk";
45             }
46              
47             # all the signals are known, install them all
48             # with the cluck handler.
49              
50 0         0 @SIG{ @_ } = ( \&Carp::cluck ) x @_;
51             }
52             else
53             {
54 1         28 $SIG{ USR1 } = \&Carp::cluck;
55             }
56              
57             return
58 1         16 }
59              
60             # keep require happy
61              
62             1
63              
64             __END__