Branch Coverage

blib/lib/Script/Daemonizer.pm
Criterion Covered Total %
branch 41 122 33.6


line true false branch
86 1 1 if ($opt eq ':NOCHDIR') { }
1 0 elsif ($opt eq ':NOUMASK') { }
108 0 5 if $$self{'_DEBUG'}
119 0 2 unless defined umask $$self{'umask'}
130 0 0 unless $$self{'fork'}
139 0 0 unless defined(my $pid = fork)
142 0 0 if $pid
157 0 1 if exists $$self{'setsid'} and $$self{'setsid'} eq 'SKIP'
158 0 1 unless POSIX::setsid()
178 0 2 if (defined $pidfd and $pidfd =~ /^\d+$/) { }
180 0 0 unless open $fh, ">&=$pidfd"
183 0 0 unless fcntl $fh, 2, 1
188 0 2 unless sysopen $fh, $pidfile, 66
191 0 2 unless flock $fh, 6
193 0 2 unless truncate $fh, 0
213 0 1 unless chdir $$self{'working_dir'}
228 0 0 unless open $fh, '>', $devnull
240 0 2 if $destination eq '/dev/null'
245 0 2 unless open $fh, '>>', $destination
256 0 1 unless open STDIN, '<', $devnull
260 1 0 if ($$self{'output_file'})
267 0 0 unless ($$self{'stdout_file'} and $$self{'stderr_file'})
273 0 0 if ($@)
274 0 0 if $$self{'_DEBUG'}
285 0 0 if ($$self{'stdout_file'}) { }
297 0 0 if ($$self{'stderr_file'}) { }
327 0 6 if @_ % 2
331 2 4 @_ ? :
335 8 4 unless defined(my $us = delete $ids{$_})
337 0 4 unless defined($ids{$id_map{$_}} = getpwnam $us)
343 8 4 unless defined(my $gr = delete $ids{$_})
345 0 4 unless defined($ids{$id_map{$_}} = getgrnam $gr)
353 6 0 if (defined $gid) { }
0 0 elsif (defined $egid) { }
354 0 6 unless POSIX::setgid((split(' ', $gid, 0))[0])
359 0 0 if $!
364 6 0 if (defined $uid) { }
0 0 elsif (defined $euid) { }
365 0 6 unless POSIX::setuid($uid)
370 0 0 if $!
382 0 15 if ref $pkg
385 1 14 if @_ % 2
397 0 14 exists $params{'fork'} && $params{'fork'} =~ /^[012]$/ ? :
401 0 14 if $params{'working_dir'}
403 0 14 if (exists $params{'umask'})
404 0 0 unless $params{'umask'} =~ /^[0-7]{1,3}$/
411 7 147 if exists $params{$_}
418 1 13 if @extra_args
425 0 13 if ($$self{'restart_on'} and ref $$self{'restart_on'} eq 'ARRAY')
436 0 13 if ($$self{'sigunmask'} and ref $$self{'sigunmask'} eq 'ARRAY')
448 0 0 if $$self{'drop_privileges'}
452 0 0 if exists $$self{'umask'}
456 0 0 if $$self{'fork'}
463 0 0 if $$self{'fork'}
468 0 0 if $$self{'pidfile'}
472 0 0 if $$self{'working_dir'}
491 0 0 @_ ? :
500 0 0 if (my $pidfh = $$self{'pidfh'})
503 0 0 unless fcntl $pidfh, 2, 0
509 0 0 unless exec $SELF, @args
518 0 0 unless @_