lib/Rex/Fork/Task.pm

filter: Statementstmt 100% 28 / 28 Branchbran 100% 4 / 4 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 3 totaltotal 84.7% 39 / 46 CC 4 SCAR 5.2
CC
4
Cov
94%
new
2.0
start
2.0
wait
2.0
CRAP 1.7
« lib/Rex/User/Base.pm ↑ Summary blib/lib/Rex/Interface/Connection.pm »
1 #
2 # (c) Jan Gehring <jan.gehring@gmail.com>
3 #
4  
5 package Rex::Fork::Task;
6  
7 56 ▶use v5.14.4;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 56 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 56 ▶use POSIX ":sys_wait_h";
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 56 our $VERSION = '1.16.1'; # VERSION
12  
13 135 ▶sub new {
Subroutine new: called CC=2 SCAR=7.1
Pod undocumented
14 135 my $that = shift;
15 135 ▶ my $proto = ref($that) || $that;
Condition33%1/3
ref $that || $that
l!l&&r!l&&!r
01350
MC/DC0%0/2
ref $that || $that
ref $that $that
Truth table33%1/3
A || B
A= ref $thatB= $that
ABresult
1X1
011
000
16 135 my $self = {@_};
17  
18 135 bless( $self, $proto );
19  
20 135 $self->{'running'} = 0;
21  
22 135 return $self;
23 }
24  
25 135 ▶sub start {
Subroutine start: called CC=2 SCAR=6.9
Pod undocumented
26 135 my ($self) = @_;
27  
28 135 $self->{'running'} = 1;
29 135 $self->{pid} = fork;
30  
31 135 ▶ if ( !$self->{pid} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->{"pid"}) 29 106 135
32 29 $self->{coderef}->($self);
33 29 $self->{'running'} = 0;
34 29 exit();
35 }
36 }
37  
38 3135 ▶sub wait {
Subroutine wait: called CC=2 SCAR=6.9
Pod undocumented
39 3135 my ($self) = @_;
40 3135 my $rpid = waitpid( $self->{pid}, &WNOHANG );
41 3135 ▶ if ( $rpid == -1 ) { $self->{'running'} = 0; }
Branch: 1 branch
BranchTrueFalseTotal
if ($rpid == -1) 106 3029 3135
42  
43 3135 return $rpid;
44 }
45  
46 56 1;
« lib/Rex/User/Base.pm ↑ Summary blib/lib/Rex/Interface/Connection.pm »