line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Proc::ChildError; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $DATE = '2015-06-26'; # DATE |
4
|
|
|
|
|
|
|
our $VERSION = '0.03'; # VERSION |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
24356
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
38
|
|
7
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
215
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
require Exporter; |
10
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
11
|
|
|
|
|
|
|
our @EXPORT_OK = qw(explain_child_error); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub explain_child_error { |
14
|
6
|
|
|
6
|
1
|
24
|
my $opts; |
15
|
6
|
100
|
|
|
|
29
|
if (ref($_[0]) eq 'HASH') { |
16
|
1
|
|
|
|
|
3
|
$opts = shift; |
17
|
|
|
|
|
|
|
} else { |
18
|
5
|
|
|
|
|
14
|
$opts = {}; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
6
|
|
|
|
|
9
|
my ($num, $str); |
22
|
6
|
100
|
|
|
|
17
|
if (defined $_[0]) { |
23
|
5
|
|
|
|
|
7
|
$num = $_[0]; |
24
|
5
|
|
|
|
|
8
|
$str = $_[1]; |
25
|
|
|
|
|
|
|
} else { |
26
|
1
|
|
|
|
|
11
|
$num = $?; |
27
|
1
|
|
|
|
|
14
|
$str = $!; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
6
|
|
|
|
|
12
|
my $prefix = ""; |
31
|
6
|
100
|
|
|
|
23
|
if (defined $opts->{prog}) { |
32
|
1
|
|
|
|
|
4
|
$prefix = "$opts->{prog} "; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
6
|
100
|
|
|
|
21
|
if ($num == -1) { |
|
|
100
|
|
|
|
|
|
36
|
2
|
100
|
|
|
|
59
|
return "${prefix}failed to execute: ".($str ? "$str ":"")."($num)"; |
37
|
|
|
|
|
|
|
} elsif ($num & 127) { |
38
|
2
|
100
|
|
|
|
41
|
return sprintf( |
39
|
|
|
|
|
|
|
"${prefix}died with signal %d, %s coredump", |
40
|
|
|
|
|
|
|
($num & 127), |
41
|
|
|
|
|
|
|
(($num & 128) ? 'with' : 'without')); |
42
|
|
|
|
|
|
|
} else { |
43
|
2
|
|
|
|
|
23
|
return sprintf("${prefix}exited with code %d", $num >> 8); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
1; |
48
|
|
|
|
|
|
|
# ABSTRACT: Explain process child error |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
__END__ |