line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
3
|
|
|
3
|
|
4027
|
use 5.006; use strict; use warnings; |
|
3
|
|
|
3
|
|
19
|
|
|
3
|
|
|
3
|
|
12
|
|
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
53
|
|
|
3
|
|
|
|
|
10
|
|
|
3
|
|
|
|
|
10
|
|
|
3
|
|
|
|
|
188
|
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Proc::Fork; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.806'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use Exporter::Tidy ( |
8
|
3
|
|
|
|
|
15
|
default => [ ':all' ], |
9
|
|
|
|
|
|
|
wrapper => [ 'run_fork' ], |
10
|
|
|
|
|
|
|
blocks => [ qw( parent child error retry ) ], |
11
|
3
|
|
|
3
|
|
2891
|
); |
|
3
|
|
|
|
|
36
|
|
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
4
|
sub _croak { require Carp; goto &Carp::croak } |
|
1
|
|
|
|
|
170
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my $do_clear = 1; |
16
|
|
|
|
|
|
|
my ( $parent, $child, $error, $retry ); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub run_fork(&) { |
19
|
8
|
|
|
8
|
1
|
15
|
my $setup = shift; |
20
|
|
|
|
|
|
|
|
21
|
8
|
|
|
|
|
201
|
my @r = $setup->(); |
22
|
8
|
50
|
|
|
|
20
|
_croak "Garbage in Proc::Fork setup (semicolon after last block clause?)" if @r; |
23
|
8
|
|
|
|
|
11
|
$do_clear = 1; |
24
|
|
|
|
|
|
|
|
25
|
8
|
|
|
|
|
14
|
my $pid; |
26
|
|
|
|
|
|
|
my $i; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
{ |
29
|
8
|
|
|
|
|
42
|
$pid = fork; |
|
12
|
|
|
|
|
1553
|
|
30
|
12
|
100
|
|
|
|
174
|
last if defined $pid; |
31
|
7
|
100
|
100
|
|
|
15
|
redo if $retry and $retry->( ++$i ); |
32
|
3
|
50
|
|
|
|
21
|
die "Cannot fork: $!\n" if not $error; |
33
|
3
|
|
|
|
|
6
|
$error->(); |
34
|
3
|
|
|
|
|
55
|
return; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
5
|
100
|
33
|
|
|
199
|
$_->( $pid || () ) for ( $pid ? $parent : $child ) || (); |
|
|
|
66
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
5
|
|
|
|
|
128361
|
return; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
for my $block ( qw( parent child error retry ) ) { |
43
|
|
|
|
|
|
|
my $code = q{sub _BLOCK_ (&;@) { |
44
|
|
|
|
|
|
|
$parent = $child = $error = $retry = $do_clear = undef if $do_clear; |
45
|
|
|
|
|
|
|
_croak "Duplicate _BLOCK_ clause in Proc::Fork setup" if $_BLOCK_; |
46
|
|
|
|
|
|
|
$_BLOCK_ = shift if 'CODE' eq ref $_[0]; |
47
|
|
|
|
|
|
|
_croak "Garbage in Proc::Fork setup (after _BLOCK_ clause)" if @_; |
48
|
|
|
|
|
|
|
run_fork {} if not defined wantarray; # backcompat |
49
|
|
|
|
|
|
|
(); |
50
|
|
|
|
|
|
|
}}; |
51
|
|
|
|
|
|
|
$code =~ s/_BLOCK_/$block/g; |
52
|
3
|
100
|
|
2
|
1
|
31
|
eval $code; |
|
3
|
50
|
|
3
|
1
|
11
|
|
|
3
|
50
|
|
3
|
1
|
12
|
|
|
3
|
50
|
|
5
|
1
|
8
|
|
|
3
|
50
|
|
2
|
|
41
|
|
|
3
|
100
|
|
|
|
3
|
|
|
3
|
50
|
|
|
|
117
|
|
|
3
|
50
|
|
|
|
13
|
|
|
3
|
50
|
|
|
|
24
|
|
|
3
|
100
|
|
|
|
6
|
|
|
3
|
50
|
|
|
|
65
|
|
|
3
|
50
|
|
|
|
45
|
|
|
5
|
50
|
|
|
|
158
|
|
|
5
|
100
|
|
|
|
12
|
|
|
5
|
100
|
|
|
|
16
|
|
|
5
|
50
|
|
|
|
15
|
|
|
4
|
50
|
|
|
|
20
|
|
|
4
|
50
|
|
|
|
38
|
|
|
2
|
50
|
|
|
|
6
|
|
|
2
|
50
|
|
|
|
3
|
|
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
2
|
|
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
1; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
__END__ |