line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# (c) Jan Gehring |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Rex::Fork::Task; |
6
|
|
|
|
|
|
|
|
7
|
56
|
|
|
56
|
|
825
|
use v5.12.5; |
|
56
|
|
|
|
|
197
|
|
8
|
56
|
|
|
56
|
|
291
|
use warnings; |
|
56
|
|
|
|
|
152
|
|
|
56
|
|
|
|
|
1650
|
|
9
|
56
|
|
|
56
|
|
604
|
use POSIX ":sys_wait_h"; |
|
56
|
|
|
|
|
64005
|
|
|
56
|
|
|
|
|
353
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '1.14.2.3'; # TRIAL VERSION |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub new { |
14
|
135
|
|
|
135
|
0
|
559
|
my $that = shift; |
15
|
135
|
|
33
|
|
|
1933
|
my $proto = ref($that) || $that; |
16
|
135
|
|
|
|
|
1038
|
my $self = {@_}; |
17
|
|
|
|
|
|
|
|
18
|
135
|
|
|
|
|
430
|
bless( $self, $proto ); |
19
|
|
|
|
|
|
|
|
20
|
135
|
|
|
|
|
624
|
$self->{'running'} = 0; |
21
|
|
|
|
|
|
|
|
22
|
135
|
|
|
|
|
445
|
return $self; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub start { |
26
|
135
|
|
|
135
|
0
|
400
|
my ($self) = @_; |
27
|
|
|
|
|
|
|
|
28
|
135
|
|
|
|
|
352
|
$self->{'running'} = 1; |
29
|
135
|
|
|
|
|
253575
|
$self->{pid} = fork; |
30
|
|
|
|
|
|
|
|
31
|
135
|
100
|
|
|
|
14283
|
if ( !$self->{pid} ) { |
32
|
29
|
|
|
|
|
4387
|
$self->{coderef}->($self); |
33
|
29
|
|
|
|
|
307
|
$self->{'running'} = 0; |
34
|
29
|
|
|
|
|
10600
|
exit(); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub wait { |
39
|
6616
|
|
|
6616
|
0
|
26938
|
my ($self) = @_; |
40
|
6616
|
|
|
|
|
136563
|
my $rpid = waitpid( $self->{pid}, &WNOHANG ); |
41
|
6616
|
100
|
|
|
|
31562
|
if ( $rpid == -1 ) { $self->{'running'} = 0; } |
|
106
|
|
|
|
|
929
|
|
42
|
|
|
|
|
|
|
|
43
|
6616
|
|
|
|
|
27698
|
return $rpid; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
1; |