blib/lib/Unix/PID/Tiny.pm

filter: Statementstmt 18.3% 28 / 153 Branchbran 4.6% 5 / 108 Conditioncond 9.0% 4 / 44 MC/DCmcdc 7.4% 2 / 27 Subroutinesub 31.2% 5 / 16 Podpod 100% 8 / 8 totaltotal 14.6% 52 / 356 CC 72 SCAR 49.7
CC
72
Cov
12%
pid_file_no_unlink
342.0
is_pidfile_running
240.0
pid_file
132.0
CRAP 144.5
↑ Summary
1 package Unix::PID::Tiny;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 our $VERSION = '0.95';
7  
8 2 ▶sub new {
Subroutine new: called CC=8 SCAR=22.3
Pod documented
9 2 my ( $self, $args_hr ) = @_;
10  
11 2 my %DEFAULTS = (
12 'keep_open' => 0,
13 'check_proc_open_fds' => 0
14 );
15  
16 2 ▶ $args_hr ||= {};
Condition100%2/2
$args_hr ||= {}
l!l
11
MC/DC100%1/1
$args_hr ||= {}
$args_hr
Truth table100%2/2
A
A= $args_hr
Aresult
11
00
17 2 %{$args_hr} = ( %DEFAULTS, %{$args_hr} );
18 2 ▶ $args_hr->{'minimum_pid'} = 11 if !exists $args_hr->{'minimum_pid'} || $args_hr->{'minimum_pid'} !~ m{\A\d+\z}ms; # this does what one assumes m{^\d+$} would do
Branch: 1 branch
BranchTrueFalseTotal
unless exists $args_hr->{"minimum_pid"} and $args_hr->{"minimum_pid"} =~ /\A\d+\z/ms 1 1 2
Condition66%2/3
exists $args_hr->{"minimum_pid"} and $args_hr->{"minimum_pid"} =~ /\A\d+\z/ms
!ll&&!rl&&r
101
MC/DC50%1/2
exists $args_hr->{"minimum_pid"} and $args_hr->{"minimum_pid"} =~ /\A\d+\z/ms
exists $args_hr->{"minimum_pid"} $args_hr->{"minimum_pid"} =~ /\A\d+\z/ms
Truth table66%2/3
A and B
A= exists $args_hr->{"minimum_pid"}B= $args_hr->{"minimum_pid"} =~ /\A\d+\z/ms
ABresult
0X0
100
111
19  
20 2 ▶ if ( defined $args_hr->{'ps_path'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $args_hr->{'ps_path'}) { } 1 1 2
21 1 ▶ $args_hr->{'ps_path'} .= '/' if $args_hr->{'ps_path'} !~ m{/$};
Branch: 1 branch
BranchTrueFalseTotal
unless $args_hr->{"ps_path"} =~ m[/$] 1 0 1
22 1 ▶ if ( !-d $args_hr->{'ps_path'} || !-x "$args_hr->{'ps_path'}ps" ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-d $args_hr->{"ps_path"} and -x qq[$args_hr->{"ps_path"}ps]) 0 0 0
Condition0%0/3
-d $args_hr->{"ps_path"} and -x qq[$args_hr->{"ps_path"}ps]
!ll&&!rl&&r
000
MC/DC0%0/2
-d $args_hr->{"ps_path"} and -x qq[$args_hr->{"ps_path"}ps]
-d $args_hr->{"ps_path"} -x qq[$args_hr->{"ps_path"}ps]
Truth table0%0/3
A and B
A= -d $args_hr->{"ps_path"}B= -x qq[$args_hr->{"ps_path"}ps]
ABresult
0X0
100
111
23 0 $args_hr->{'ps_path'} = '';
24 }
25 }
26 else {
27 1 $args_hr->{'ps_path'} = '';
28 }
29  
30 return bless {
31 'ps_path' => $args_hr->{'ps_path'},
32 'minimum_pid' => $args_hr->{'minimum_pid'},
33 'keep_open' => $args_hr->{'keep_open'},
34 1 'check_proc_open_fds' => $args_hr->{'check_proc_open_fds'},
35 'open_handles' => []
36 }, $self;
37 }
38  
39 0 ▶sub kill {
Subroutine kill: not called CC=6 SCAR=37.4
Pod documented
40 0 my ( $self, $pid, $give_kill_a_chance ) = @_;
41 0 ▶ $give_kill_a_chance = int $give_kill_a_chance if defined $give_kill_a_chance;
Branch: 1 branch
BranchTrueFalseTotal
if defined $give_kill_a_chance 0 0 0
42 0 $pid = int $pid;
43 0 my $min = int $self->{'minimum_pid'};
44 0 ▶ if ( $pid < $min ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pid < $min) 0 0 0
45  
46 # prevent bad args from killing the process group (IE '0')
47 # or general low level ones
48 0 warn "kill() called with integer value less than $min";
49 0 return;
50 }
51  
52 # CORE::kill 0, $pid : may be false but still running, see `perldoc -f kill`
53 0 ▶ if ( $self->is_pid_running($pid) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->is_pid_running($pid)) 0 0 0
54  
55 # RC from CORE::kill is not a boolean of if the PID was killed or not, only that it was signaled
56 # so it is not an indicator of "success" in killing $pid
57 0 _kill( 15, $pid ); # TERM
58 0 _kill( 2, $pid ); # INT
59 0 _kill( 1, $pid ); # HUP
60 0 _kill( 9, $pid ); # KILL
61  
62 # give kill() some time to take effect?
63 0 ▶ if ($give_kill_a_chance) {
Branch: 1 branch
BranchTrueFalseTotal
if ($give_kill_a_chance) 0 0 0
64 0 sleep($give_kill_a_chance);
65 }
66 0 ▶ return if $self->is_pid_running($pid);
Branch: 1 branch
BranchTrueFalseTotal
if $self->is_pid_running($pid) 0 0 0
67 }
68 0 return 1;
69 }
70  
71 0 ▶sub is_pid_running {
Subroutine is_pid_running: not called CC=9 SCAR=45.0
Pod documented
72 0 my ( $self, $check_pid ) = @_;
73  
74 0 $check_pid = int $check_pid;
75 0 ▶ return if !$check_pid || $check_pid < 0;
Branch: 1 branch
BranchTrueFalseTotal
if not $check_pid or $check_pid < 0 0 0 0
Condition0%0/3
not $check_pid or $check_pid < 0
l!l&&r!l&&!r
000
MC/DC0%0/2
not $check_pid or $check_pid < 0
not $check_pid $check_pid < 0
Truth table0%0/3
not(A) or B
A= not $check_pidB= $check_pid < 0
ABresult
1X1
011
000
76  
77 0 ▶ return 1 if $> == 0 && _kill( 0, $check_pid ); # if we are superuser we can avoid the the system call. For details see `perldoc -f kill`
Branch: 1 branch
BranchTrueFalseTotal
if $> == 0 and _kill(0, $check_pid) 0 0 0
Condition0%0/3
$> == 0 and _kill(0, $check_pid)
!ll&&!rl&&r
000
MC/DC0%0/2
$> == 0 and _kill(0, $check_pid)
$> == 0 _kill(0, $check_pid)
Truth table0%0/3
A and B
A= $> == 0B= _kill(0, $check_pid)
ABresult
0X0
100
111
78  
79 # If the proc filesystem is available, it's a good test. If not, continue on to system call
80 0 ▶ return 1 if -e "/proc/$$" && -r "/proc/$$" && -r "/proc/$check_pid";
Branch: 1 branch
BranchTrueFalseTotal
if -e "/proc/${$}" and -r "/proc/${$}" and -r "/proc/$check_pid" 0 0 0
Condition0%0/6
-e "/proc/${$}" and -r "/proc/${$}" and -r "/proc/$check_pid"
!ll&&!rl&&r
000
-e "/proc/${$}" and -r "/proc/${$}"
!ll&&!rl&&r
000
MC/DC0%0/3
-e "/proc/${$}" and -r "/proc/${$}" and -r "/proc/$check_pid"
-e "/proc/${$}" -r "/proc/${$}" -r "/proc/$check_pid"
Truth table0%0/4
A and B and C
A= -e "/proc/${$}"B= -r "/proc/${$}"C= -r "/proc/$check_pid"
ABCresult
0XX0
10X0
1100
1111
81  
82 # even if we are superuser, go ahead and call ps just in case CORE::kill 0's false RC was erroneous
83 0 my @outp = $self->_raw_ps( 'u', '-p', $check_pid );
84 0 chomp @outp;
85 0 ▶ return 1 if defined $outp[1];
Branch: 1 branch
BranchTrueFalseTotal
if defined $outp[1] 0 0 0
86 0 return;
87 }
88  
89 0 ▶sub pid_info_hash {
Subroutine pid_info_hash: not called CC=4 SCAR=30.0
Pod documented
90 0 my ( $self, $pid ) = @_;
91 0 $pid = int $pid;
92 0 ▶ return if !$pid || $pid < 0;
Branch: 1 branch
BranchTrueFalseTotal
if not $pid or $pid < 0 0 0 0
Condition0%0/3
not $pid or $pid < 0
l!l&&r!l&&!r
000
MC/DC0%0/2
not $pid or $pid < 0
not $pid $pid < 0
Truth table0%0/3
not(A) or B
A= not $pidB= $pid < 0
ABresult
1X1
011
000
93  
94 0 my @outp = $self->_raw_ps( 'u', '-p', $pid );
95 0 chomp @outp;
96 0 my %info;
97 0 @info{ split( /\s+/, $outp[0], 11 ) } = split( /\s+/, $outp[1], 11 );
98 0 ▶ return wantarray ? %info : \%info;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
99 }
100  
101 0 ▶sub _raw_ps {
Subroutine _raw_ps: not called CC=2 SCAR=17.9
102 0 my ( $self, @ps_args ) = @_;
103 0 my $psargs = join( ' ', @ps_args );
104 0 my @res = `$self->{'ps_path'}ps $psargs`;
105 0 ▶ return wantarray ? @res : join '', @res;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
106 }
107  
108 0 ▶sub get_pid_from_pidfile {
Subroutine get_pid_from_pidfile: not called CC=3 SCAR=24.8
Pod documented
109 0 my ( $self, $pid_file ) = @_;
110  
111 # if this function is ever changed to use $self as a hash object, update pid_file() to not do a class method call
112 0 ▶ return 0 if !-e $pid_file;
Branch: 1 branch
BranchTrueFalseTotal
unless -e $pid_file 0 0 0
113  
114 0 ▶ open my $pid_fh, '<', $pid_file or return;
Branch: 1 branch
BranchTrueFalseTotal
open my $pid_fh, "<", $pid_file or return 0 0 0
115 0 chomp( my $pid = <$pid_fh> );
116 0 close $pid_fh;
117  
118 0 return int( abs($pid) );
119 }
120  
121 0 ▶sub _sets_match {
Subroutine _sets_match: not called CC=4 SCAR=30.0
122 0 my ( $left, $right ) = @_;
123  
124 0 my $count = scalar @{$left};
125  
126 0 ▶ return 0 unless scalar @{$right} == $count;
Branch: 1 branch
BranchTrueFalseTotal
unless scalar @{$right;} == $count 0 0 0
127  
128 0 ▶ for ( my $i = 0; $i < $count; $i++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $count) 0 0 0
129 0 ▶ return 0 unless $left->[$i] eq $right->[$i];
Branch: 1 branch
BranchTrueFalseTotal
unless $left->[$i] eq $right->[$i] 0 0 0
130 }
131  
132 0 return 1;
133 }
134  
135 0 ▶sub is_pidfile_running {
Subroutine is_pidfile_running: not called CC=15 SCAR=54.8
Pod documented
136 0 my ( $self, $pid_file, $since ) = @_;
137 0 ▶ my $pid = $self->get_pid_from_pidfile($pid_file) || return;
Condition0%0/2
$self->get_pid_from_pidfile($pid_file) || (return)
l!l
00
MC/DC0%0/1
$self->get_pid_from_pidfile($pid_file) || (return)
$self->get_pid_from_pidfile($pid_file)
Truth table0%0/2
A
A= $self->get_pid_from_pidfile($pid_file)
Aresult
11
00
138  
139 0 ▶ my @pidfile_st = stat $pid_file or return;
Branch: 1 branch
BranchTrueFalseTotal
my(@pidfile_st) = stat $pid_file or return 0 0 0
140  
141 0 ▶ if ( defined $since ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $since) 0 0 0
142 0 ▶ return if $pidfile_st[9] < $since;
Branch: 1 branch
BranchTrueFalseTotal
if $pidfile_st[9] < $since 0 0 0
143 }
144  
145 0 ▶ if ( $self->{'check_proc_open_fds'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'check_proc_open_fds'}) { } 0 0 0
146 0 my $dir = "/proc/$pid/fd";
147 0 my $found = 0;
148  
149 0 ▶ opendir my $dh, $dir or return;
Branch: 1 branch
BranchTrueFalseTotal
opendir my $dh, $dir or return 0 0 0
150  
151 0 ▶ while ( my $dirent = readdir $dh ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $dirent = readdir $dh)) 0 0 0
152 0 ▶ next if $dirent eq '.' || $dirent eq '..';
Branch: 1 branch
BranchTrueFalseTotal
if $dirent eq "." or $dirent eq ".." 0 0 0
Condition0%0/3
$dirent eq "." or $dirent eq ".."
l!l&&r!l&&!r
000
MC/DC0%0/2
$dirent eq "." or $dirent eq ".."
$dirent eq "." $dirent eq ".."
Truth table0%0/3
A or B
A= $dirent eq "."B= $dirent eq ".."
ABresult
1X1
011
000
153  
154 0 my $path = "$dir/$dirent";
155 0 ▶ my $dest = readlink $path or next;
Branch: 1 branch
BranchTrueFalseTotal
my $dest = readlink $path or next 0 0 0
156 0 ▶ my @st = stat $dest or next;
Branch: 1 branch
BranchTrueFalseTotal
my(@st) = stat $dest or next 0 0 0
157  
158 0 ▶ if ( _sets_match( [ @pidfile_st[ 0, 1 ] ], [ @st[ 0, 1 ] ] ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (_sets_match([@pidfile_st[0, 1]], [@st[0, 1]])) 0 0 0
159 0 $found = 1;
160  
161 0 last;
162 }
163 }
164  
165 0 closedir $dh;
166  
167 0 ▶ return unless $found;
Branch: 1 branch
BranchTrueFalseTotal
unless $found 0 0 0
168 }
169 else {
170 0 ▶ return unless $self->is_pid_running($pid);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->is_pid_running($pid) 0 0 0
171 }
172  
173 0 return $pid;
174 }
175  
176 0 ▶sub pid_file {
Subroutine pid_file: not called CC=11 SCAR=48.8
Pod documented
177 0 my ( $self, $pid_file, $newpid, $retry_conf ) = @_;
178 0 ▶ $newpid = $$ if !$newpid;
Branch: 1 branch
BranchTrueFalseTotal
unless $newpid 0 0 0
179  
180 0 my $rc = $self->pid_file_no_unlink( $pid_file, $newpid, $retry_conf );
181 0 ▶ if ( $rc && $newpid == $$ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rc and $newpid == $$) 0 0 0
Condition0%0/3
$rc and $newpid == $$
!ll&&!rl&&r
000
MC/DC0%0/2
$rc and $newpid == $$
$rc $newpid == $$
Truth table0%0/3
A and B
A= $rcB= $newpid == $$
ABresult
0X0
100
111
182  
183 # prevent forked childrens' END from killing parent's pid files
184 # 'unlink_end_use_current_pid_only' is undocumented as this may change, feedback welcome!
185 # 'carp_unlink_end' undocumented as it is only meant for testing (rt57462, use Test::Carp to test END behavior)
186 0 ▶ if ( $self->{'unlink_end_use_current_pid_only'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'unlink_end_use_current_pid_only'}) { } 0 0 0
187 0 eval 'END { unlink $pid_file if $$ eq ' . $$ . '}'; ## no critic qw(ProhibitStringyEval)
188 0 ▶ if ( $self->{'carp_unlink_end'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"carp_unlink_end"}) 0 0 0
189  
190 # eval 'END { require Carp;Carp::carp("[info] $$ !unlink $pid_file (current pid check)") if $$ ne ' . $$ . '}'; ## no critic qw(ProhibitStringyEval)
191 0 eval 'END { require Carp;Carp::carp("[info] $$ unlink $pid_file (current pid check)") if $$ eq ' . $$ . '}'; ## no critic qw(ProhibitStringyEval)
192 }
193 }
194 else {
195 0 eval 'END { unlink $pid_file if Unix::PID::Tiny->get_pid_from_pidfile($pid_file) eq $$ }'; ## no critic qw(ProhibitStringyEval)
196 0 ▶ if ( $self->{'carp_unlink_end'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"carp_unlink_end"}) 0 0 0
197  
198 # eval 'END { require Carp;Carp::carp("[info] $$ !unlink $pid_file (pid file check)") if Unix::PID::Tiny->get_pid_from_pidfile($pid_file) ne $$ }'; ## no critic qw(ProhibitStringyEval)
199 0 eval 'END { require Carp;Carp::carp("[info] $$ unlink $pid_file (pid file check)") if Unix::PID::Tiny->get_pid_from_pidfile($pid_file) eq $$ }'; ## no critic qw(ProhibitStringyEval)
200 }
201 }
202 }
203  
204 0 ▶ return 1 if defined $rc && $rc == 1;
Branch: 1 branch
BranchTrueFalseTotal
if defined $rc and $rc == 1 0 0 0
Condition0%0/3
defined $rc and $rc == 1
!ll&&!rl&&r
000
MC/DC0%0/2
defined $rc and $rc == 1
defined $rc $rc == 1
Truth table0%0/3
A and B
A= defined $rcB= $rc == 1
ABresult
0X0
100
111
205 0 ▶ return 0 if defined $rc && $rc == 0;
Branch: 1 branch
BranchTrueFalseTotal
if defined $rc and $rc == 0 0 0 0
Condition0%0/3
defined $rc and $rc == 0
!ll&&!rl&&r
000
MC/DC0%0/2
defined $rc and $rc == 0
defined $rc $rc == 0
Truth table0%0/3
A and B
A= defined $rcB= $rc == 0
ABresult
0X0
100
111
206 0 return;
207 }
208  
209 2 ▶no warnings 'once';
Subroutine BEGIN: called CC=1 SCAR=0.0
210  
211 # more intuitively named alias
212 2 *pid_file_no_cleanup = \&pid_file_no_unlink;
213 2 ▶use warnings 'once';
Subroutine BEGIN: called CC=1 SCAR=0.0
214  
215 0 ▶sub pid_file_no_unlink {
Subroutine pid_file_no_unlink: not called CC=18 SCAR=58.3
Pod documented
216 0 my ( $self, $pid_file, $newpid, $retry_conf ) = @_;
217 0 ▶ $newpid = $$ if !$newpid;
Branch: 1 branch
BranchTrueFalseTotal
unless $newpid 0 0 0
218  
219 0 ▶ if ( ref($retry_conf) eq 'ARRAY' ) {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $retry_conf eq 'ARRAY') { } 0 0 0
elsif (ref $retry_conf eq 'HASH') { } 0 0 0
220 0 $retry_conf->[0] = int( abs( $retry_conf->[0] ) );
221 0 for my $idx ( 1 .. scalar( @{$retry_conf} ) - 1 ) {
222 0 ▶ next if ref $retry_conf->[$idx] eq 'CODE';
Branch: 1 branch
BranchTrueFalseTotal
if ref $retry_conf->[$idx] eq "CODE" 0 0 0
223 0 $retry_conf->[$idx] = int( abs( $retry_conf->[$idx] ) );
224 }
225 }
226 elsif ( ref($retry_conf) eq 'HASH' ) {
227 0 ▶ $retry_conf->{'num_of_passes'} ||= 3;
Condition0%0/2
$retry_conf->{"num_of_passes"} ||= 3
l!l
00
MC/DC0%0/1
$retry_conf->{"num_of_passes"} ||= 3
$retry_conf->{"num_of_passes"}
Truth table0%0/2
A
A= $retry_conf->{"num_of_passes"}
Aresult
11
00
228 0 ▶ $retry_conf->{'passes_config'} ||= [ 1, 2 ];
Condition0%0/2
$retry_conf->{"passes_config"} ||= [1, 2]
l!l
00
MC/DC0%0/1
$retry_conf->{"passes_config"} ||= [1, 2]
$retry_conf->{"passes_config"}
Truth table0%0/2
A
A= $retry_conf->{"passes_config"}
Aresult
11
00
229 0 $retry_conf = [ int( $retry_conf->{'num_of_passes'} ), @{ $retry_conf->{'passes_config'} } ];
230 }
231 else {
232 0 $retry_conf = [ 3, 1, 2 ];
233 }
234  
235 0 my $passes = 0;
236 0 require Fcntl;
237  
238 0 EXISTS:
239 $passes++;
240 0 ▶ if ( -e $pid_file ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-e $pid_file) 0 0 0
241 0 my $curpid = $self->get_pid_from_pidfile($pid_file);
242  
243 # TODO: narrow even more the race condition where $curpid stops running and a new PID is put in
244 # the file between when we pull in $curpid above and check to see if it is running/unlink below
245  
246 0 ▶ return 1 if int $curpid == $$ && $newpid == $$; # already setup
Branch: 1 branch
BranchTrueFalseTotal
if int $curpid == $$ and $newpid == $$ 0 0 0
Condition0%0/3
int $curpid == $$ and $newpid == $$
!ll&&!rl&&r
000
MC/DC0%0/2
int $curpid == $$ and $newpid == $$
int $curpid == $$ $newpid == $$
Truth table0%0/3
A and B
A= int $curpid == $$B= $newpid == $$
ABresult
0X0
100
111
247 0 ▶ return if int $curpid == $$; # can't change it while $$ is alive
Branch: 1 branch
BranchTrueFalseTotal
if int $curpid == $$ 0 0 0
248 0 ▶ return if $self->is_pid_running( int $curpid );
Branch: 1 branch
BranchTrueFalseTotal
if $self->is_pid_running(int $curpid) 0 0 0
249  
250 0 unlink $pid_file; # must be a stale PID file, so try to remove it for sysopen()
251 }
252  
253 # write only if it does not exist:
254 0 my $pid_fh = _sysopen($pid_file);
255 0 ▶ if ( !$pid_fh ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($pid_fh) 0 0 0
256 0 ▶ return 0 if $passes >= $retry_conf->[0];
Branch: 1 branch
BranchTrueFalseTotal
if $passes >= $retry_conf->[0] 0 0 0
257 0 ▶ if ( ref( $retry_conf->[$passes] ) eq 'CODE' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $retry_conf->[$passes] eq 'CODE') { } 0 0 0
258 0 $retry_conf->[$passes]->( $self, $pid_file, $passes );
259 }
260 else {
261 0 ▶ sleep( $retry_conf->[$passes] ) if $retry_conf->[$passes];
Branch: 1 branch
BranchTrueFalseTotal
if $retry_conf->[$passes] 0 0 0
262 }
263 0 goto EXISTS;
264 }
265  
266 0 syswrite( $pid_fh, int( abs($newpid) ) );
267  
268 0 ▶ if ( $self->{'keep_open'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'keep_open'}) { } 0 0 0
269 0 push @{ $self->{'open_handles'} }, $pid_fh;
270 }
271 else {
272 0 close $pid_fh;
273 }
274  
275 0 return 1;
276 }
277  
278 0 ▶sub _sysopen {
Subroutine _sysopen: not called CC=2 SCAR=17.9
279 0 my ($pid_file) = @_;
280 0 ▶ sysopen( my $pid_fh, $pid_file, Fcntl::O_WRONLY() | Fcntl::O_EXCL() | Fcntl::O_CREAT() ) || return;
Branch: 1 branch
BranchTrueFalseTotal
sysopen my $pid_fh, $pid_file, 193 or return 0 0 0
281 0 return $pid_fh;
282 }
283  
284 0 ▶sub _kill { ## no critic(RequireArgUnpacking
Subroutine _kill: not called CC=1 SCAR=0.0
285 1 return CORE::kill(@_); # goto &CORE::kill; is problematic
286 }
287  
288 1 1;
289  
290 __END__
↑ Summary