| 1 | package Class::Usul::IPC::Cmd; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 17 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 17 | ▶ | use Class::Null; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 17 | ▶ | use Class::Usul::Constants qw( EXCEPTION_CLASS FALSE NUL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 17 | OK SPC TRUE UNDEFINED_RV ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 17 | ▶ | use Class::Usul::Functions qw( arg_list emit_to io is_arrayref | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | is_coderef is_hashref is_member is_win32 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | nonblocking_write_pipe_pair | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 17 | strip_leader throw ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 17 | ▶ | use Class::Usul::Time qw( nap ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 17 | ▶ | use Class::Usul::Types qw( ArrayRef Bool LoadableClass Logger | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | NonEmptySimpleStr Num Object PositiveInt | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 17 | SimpleStr Str Undef ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 17 | ▶ | use English qw( -no_match_vars ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 17 | ▶ | use File::Basename qw( basename ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 17 | ▶ | use File::DataClass::Types qw( Directory Path ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 17 | ▶ | use File::Spec::Functions qw( devnull rootdir tmpdir ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 17 | ▶ | use IO::Handle; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 17 | ▶ | use IO::Select; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 17 | ▶ | use IPC::Open3; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 17 | ▶ | use Module::Load::Conditional qw( can_load ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 17 | ▶ | use POSIX qw( _exit setsid sysconf WIFEXITED WNOHANG ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 17 | ▶ | use Scalar::Util qw( blessed openhandle weaken ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 17 | ▶ | use Socket qw( AF_UNIX SOCK_STREAM PF_UNSPEC ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 17 | ▶ | use Sub::Install qw( install_sub ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 17 | ▶ | use Try::Tiny; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 17 | ▶ | use Unexpected::Functions qw( TimeOut Unspecified ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 17 | ▶ | use Moo; use warnings NONFATAL => 'all'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 17 | our ($CHILD_ENUM, $CHILD_PID); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | # Public attributes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 17 | has 'async' => is => 'ro', isa => Bool, default => FALSE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 17 | has 'close_all_files' => is => 'ro', isa => Bool, default => FALSE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 17 | has 'cmd' => is => 'ro', isa => ArrayRef | Str, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | required => TRUE; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 17 | has 'detach' => is => 'ro', isa => Bool, default => FALSE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 17 | has 'err' => is => 'ro', isa => Path | SimpleStr, default => NUL; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 17 | has 'expected_rv' => is => 'ro', isa => PositiveInt, default => 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 75 | ▶ | has 'ignore_zombies' => is => 'lazy', isa => Bool, builder => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_ignore_zombies: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 75 | ▶ | ($_[ 0 ]->async || $_[ 0 ]->detach) ? TRUE : FALSE }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$_[0]->async or $_[0]->detach
$_[0]->async or $_[0]->detach
MC/DC100%2/2
$_[0]->async or $_[0]->detach
$_[0]->async
$_[0]->detach
MC/DC100%2/2
$_[0]->async or $_[0]->detach
$_[0]->async
$_[0]->detach
Truth table100%3/3
A or B
A= $_[0]->asyncB= $_[0]->detach
Truth table100%3/3
A or B
A= $_[0]->asyncB= $_[0]->detach
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 356 | ▶ | has 'in' => is => 'ro', isa => Path | SimpleStr, coerce => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 356 | ▶ | (is_arrayref $_[ 0 ]) ? join $RS, @{ $_[ 0 ] } : $_[ 0 ] }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 17 | default => NUL; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | has 'log' => is => 'lazy', isa => Logger, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | ▶ | builder => sub { Class::Null->new }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | has 'keep_fhs' => is => 'lazy', isa => ArrayRef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | builder => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_keep_fhs: not called CC=2 SCAR=9.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | $_[ 0 ]->log->can( 'filehandle' ) ? [ $_[ 0 ]->log->filehandle ] : [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 17 | has 'max_pidfile_wait' => is => 'ro', isa => PositiveInt, default => 15; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 17 | has 'nap_time' => is => 'ro', isa => Num, default => 0.3; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 17 | has 'out' => is => 'ro', isa => Path | SimpleStr, default => NUL; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 17 | has 'partition_cmd' => is => 'ro', isa => Bool, default => TRUE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | has 'pidfile' => is => 'lazy', isa => Path, coerce => TRUE, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 216 | ▶ | builder => sub { $_[ 0 ]->rundir->tempfile }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_pidfile: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 17 | has 'response_class' => is => 'lazy', isa => LoadableClass, coerce => TRUE, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | default => 'Class::Usul::Response::IPC'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | has 'rundir' => is => 'lazy', isa => Directory, coerce => TRUE, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | builder => sub { $_[ 0 ]->tempdir }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.4
Subroutine
_build_rundir: called CC=1 SCAR=0.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | has 'tempdir' => is => 'lazy', isa => Directory, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | ▶ | builder => sub { tmpdir }, coerce => TRUE, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.4
Subroutine
_build_tempdir: called CC=1 SCAR=0.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | handles => { _tempfile => 'tempfile' }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 17 | has 'timeout' => is => 'ro', isa => PositiveInt, default => 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 17 | has 'use_ipc_run' => is => 'ro', isa => Bool, default => FALSE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 17 | has 'use_system' => is => 'ro', isa => Bool, default => FALSE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | has 'working_dir' => is => 'lazy', isa => Directory | Undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 12 | ▶ | default => sub { $_[ 0 ]->detach ? io rootdir : undef }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 17 | coerce => TRUE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | # Private functions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 17 | ▶ | my $_child_handler; $_child_handler = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=24.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 52 | local $OS_ERROR; # So that waitpid does not step on existing value | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 52 | ▶ | while ((my $child_pid = waitpid -1, WNOHANG) > 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | if (WIFEXITED( $CHILD_ERROR ) and $child_pid > ($CHILD_PID || 0)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
WIFEXITED($Class::Usul::IPC::Cmd::CHILD_ERROR) and $child_pid > ($Class::Usul::IPC::Cmd::CHILD_PID || 0)
$Class::Usul::IPC::Cmd::CHILD_PID || 0
MC/DC0%0/2
WIFEXITED($Class::Usul::IPC::Cmd::CHILD_ERROR) and $child_pid > ($Class::Usul::IPC::Cmd::CHILD_PID || 0)
WIFEXITED($Class::Usul::IPC::Cmd::CHILD_ERROR)
$child_pid > ($Class::Usul::IPC::Cmd::CHILD_PID || 0)
MC/DC0%0/1
$Class::Usul::IPC::Cmd::CHILD_PID || 0
$Class::Usul::IPC::Cmd::CHILD_PID
Truth table0%0/3
A and B
A= WIFEXITED($Class::Usul::IPC::Cmd::CHILD_ERROR)B= $child_pid > ($Class::Usul::IPC::Cmd::CHILD_PID || 0)
Truth table0%0/2
A
A= $Class::Usul::IPC::Cmd::CHILD_PID
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | $CHILD_PID = $child_pid; $CHILD_ENUM = $CHILD_ERROR; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 52 | $SIG{CHLD} = $_child_handler; # In case of unreliable signals | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 52 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 17 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 84 | ▶ | my $_close_child_io = sub { # In the parent, close the child end of the pipes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 84 | my $pipes = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 84 | close $pipes->[ 0 ]->[ 0 ]; undef $pipes->[ 0 ]->[ 0 ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 84 | close $pipes->[ 1 ]->[ 1 ]; undef $pipes->[ 1 ]->[ 1 ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 84 | close $pipes->[ 2 ]->[ 1 ]; undef $pipes->[ 2 ]->[ 1 ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 84 | close $pipes->[ 3 ]->[ 1 ]; undef $pipes->[ 3 ]->[ 1 ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 84 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 17 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 154 | ▶ | my $_drain = sub { # Suck up the output from the child process | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 154 | my (%hands, @ready); my $selector = IO::Select->new(); my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 154 | ▶ | while (defined (my $fh = $_[ $i ])) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 308 | $selector->add( $fh ); $hands{ fileno $fh } = $_[ $i + 1 ]; $i += 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 154 | ▶ | while (@ready = $selector->can_read) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 237 | for my $fh (@ready) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 367 | my $buf; my $bytes_read = sysread $fh, $buf, 64 * 1024; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 367 | ▶ | if ($bytes_read) { $hands{ fileno $fh }->( "${buf}" ) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 282 | else { $selector->remove( $fh ); close $fh } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 141 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 17 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 160 | ▶ | my $_err_handler = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 160 | my ($err, $filtered, $standard) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 45 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=6 SCAR=18.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 45 | ▶ | my $buf = shift; defined $buf or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 45 | ▶ | blessed $err and $err->append( $buf ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 45 | ▶ | $err eq 'out' and ${ $filtered } .= $buf; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 45 | ▶ | $err ne 'null' and ${ $standard } .= $buf; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 45 | ▶ | $err eq 'stderr' and emit_to \*STDERR, $buf; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 45 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 160 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 211 | ▶ | my $_filter_out = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 611 | return join "\n", map { strip_leader $_ } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 211 | grep { not m{ (?: Started | Finished ) }msx } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | split m{ [\n] }msx, $_[ 0 ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 17 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 96 | ▶ | my $_four_nonblocking_pipe_pairs = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 96 | return [ nonblocking_write_pipe_pair, nonblocking_write_pipe_pair, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | nonblocking_write_pipe_pair, nonblocking_write_pipe_pair ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 17 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 356 | ▶ | my $_has_shell_meta = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=8 SCAR=23.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 356 | ▶ | return (is_arrayref $_[ 0 ] && is_member '|', $_[ 0 ]) ? TRUE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
Condition66%4/6
&is_arrayref($_[0]) and &is_member("|", $_[0])
&is_arrayref($_[0]) and &is_member("&&", $_[0])
MC/DC0%0/2
&is_arrayref($_[0]) and &is_member("|", $_[0])
&is_arrayref($_[0])
&is_member("|", $_[0])
MC/DC0%0/2
&is_arrayref($_[0]) and &is_member("&&", $_[0])
&is_arrayref($_[0])
&is_member("&&", $_[0])
Truth table66%2/3
A and B
A= &is_arrayref($_[0])B= &is_member("|", $_[0])
Truth table66%2/3
A and B
A= &is_arrayref($_[0])B= &is_member("&&", $_[0])
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | : (is_arrayref $_[ 0 ] && is_member '&&', $_[ 0 ]) ? TRUE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | : ( is_arrayref $_[ 0 ]) ? FALSE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | : ( $_[ 0 ] =~ m{ [|] }mx) ? TRUE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | : ( $_[ 0 ] =~ m{ [&][&] }mx) ? TRUE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | : FALSE; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 17 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 273 | ▶ | my $_make_socket_pipe = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 273 | ▶ | socketpair( $_[ 0 ], $_[ 1 ], AF_UNIX, SOCK_STREAM, PF_UNSPEC ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | or throw $EXTENDED_OS_ERROR; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 273 | shutdown ( $_[ 0 ], 1 ); # No more writing for reader | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 273 | shutdown ( $_[ 1 ], 0 ); # No more reading for writer | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 273 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 17 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 160 | ▶ | my $_out_handler = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 160 | my ($out, $filtered, $standard) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 40 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=6 SCAR=19.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 40 | ▶ | my $buf = shift; defined $buf or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 40 | ▶ | blessed $out and $out->append( $buf ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 40 | ▶ | $out ne 'null' and ${ $filtered } .= $buf; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 40 | ▶ | $out ne 'null' and ${ $standard } .= $buf; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 40 | ▶ | $out eq 'stdout' and emit_to \*STDOUT, $buf; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 40 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 160 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 78 | ▶ | my $_partition_command = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=6 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 78 | my $cmd = shift; my $aref = []; my @command = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 78 | ▶ | for my $item (grep { defined && length } @{ $cmd }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
defined $_ && length $_
MC/DC0%0/2
defined $_ && length $_
defined $_
length $_
Truth table33%1/3
A && B
A= defined $_B= length $_
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 182 | ▶ | if ($item !~ m{ [^\\][\<\>\|\&] }mx) { push @{ $aref }, $item } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | else { push @command, $aref, $item; $aref = [] } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 78 | ▶ | if ($aref->[ 0 ]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | ▶ | if ($command[ 0 ]) { push @command, $aref } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 78 | else { @command = @{ $aref } } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 78 | return \@command; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 17 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 17 | ▶ | my $_pipe_handler; $_pipe_handler = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=4.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | local $OS_ERROR; # So that wait does not step on existing value | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | $CHILD_PID = wait; $CHILD_ENUM = (255 << 8) + 13; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | $SIG{PIPE} = $_pipe_handler; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 17 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 99 | ▶ | my $_quote = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 99 | ▶ | my $v = shift; return is_win32 ? '"'.$v.'"' : "'${v}'"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 17 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 187 | ▶ | my $_quoted_join = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 187 | ▶ | return join SPC, map { m{ [ ] }mx ? $_quote->( $_ ) : $_ } @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 17 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 69 | ▶ | my $_recv_exec_failure = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=14.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 69 | my $fh = shift; my $to_read = 2 * length pack 'I', 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 69 | ▶ | read $fh, my $buf = NUL, $to_read or return FALSE; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 1 | (my $errno, $to_read) = unpack 'II', $buf; $ERRNO = $errno; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 1 | ▶ | read $fh, my $error = NUL, $to_read; $error and utf8::decode $error; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 1 | ▶ | return $error || "${ERRNO}"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$error || "$Class::Usul::IPC::Cmd::ERRNO"
MC/DC0%0/2
$error || "$Class::Usul::IPC::Cmd::ERRNO"
$error
"$Class::Usul::IPC::Cmd::ERRNO"
Truth table33%1/3
A || B
A= $errorB= "$Class::Usul::IPC::Cmd::ERRNO"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 17 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 12 | ▶ | my $_redirect_stderr = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 12 | my $v = shift; my $err = \*STDERR; close $err; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 12 | ▶ | my $op = openhandle $v ? '>&' : '>'; my $sink = $op eq '>' ? $v : fileno $v; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 12 | ▶ | open $err, $op, $sink | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | or throw "Could not redirect STDERR to ${sink}: ${OS_ERROR}"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 12 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 17 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 12 | ▶ | my $_redirect_stdin = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 12 | my $v = shift; my $in = \*STDIN; close $in; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 12 | ▶ | my $op = openhandle $v ? '<&' : '<'; my $src = $op eq '<' ? $v : fileno $v; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 12 | ▶ | open $in, $op, $src | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | or throw "Could not redirect STDIN from ${src}: ${OS_ERROR}"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 12 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 17 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 12 | ▶ | my $_redirect_stdout = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 12 | my $v = shift; my $out = \*STDOUT; close $out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 12 | ▶ | my $op = openhandle $v ? '>&' : '>'; my $sink = $op eq '>' ? $v : fileno $v; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 12 | ▶ | open $out, $op, $sink | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | or throw "Could not redirect STDOUT to ${sink}: ${OS_ERROR}"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 12 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 17 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | ▶ | my $_send_exec_failure = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | my ($fh, $error) = @_; utf8::encode $error; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | emit_to $fh, pack 'IIa*', 0+$ERRNO, length $error, $error; close $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | _exit 255; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 17 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 154 | ▶ | my $_send_in = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=17.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 154 | ▶ | my ($fh, $in) = @_; $in or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | ▶ | if (blessed $in) { emit_to $fh, $in->slurp } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 15 | ▶ | elsif ($in ne 'null' and $in ne 'stdin') { emit_to $fh, $in } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$in ne "null" and $in ne "stdin"
MC/DC0%0/2
$in ne "null" and $in ne "stdin"
$in ne "null"
$in ne "stdin"
Truth table33%1/3
A and B
A= $in ne "null"B= $in ne "stdin"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 15 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 17 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 91 | ▶ | my $_open3 = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 91 | local (*TO_CHLD_R, *TO_CHLD_W); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 91 | local (*FR_CHLD_R, *FR_CHLD_W); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 91 | local (*FR_CHLD_ERR_R, *FR_CHLD_ERR_W); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 91 | $_make_socket_pipe->( *TO_CHLD_R, *TO_CHLD_W ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 91 | $_make_socket_pipe->( *FR_CHLD_R, *FR_CHLD_W ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 91 | $_make_socket_pipe->( *FR_CHLD_ERR_R, *FR_CHLD_ERR_W ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 91 | my $pid = open3( '>&TO_CHLD_R', '<&FR_CHLD_W', '<&FR_CHLD_ERR_W', @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 91 | return ($pid, *TO_CHLD_W, *FR_CHLD_R, *FR_CHLD_ERR_R); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 17 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | # Private methods | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 1 | ▶ | my $_detach_process = sub { # And this method came from MooseX::Daemonize | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=7 SCAR=26.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 1 | ▶ | setsid or throw 'Cannot detach from controlling process'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 1 | ▶ | $SIG{HUP} = 'IGNORE'; fork and _exit OK; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | # Clearing file creation mask allows direct control of the access mode of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | # created files and directories in open, mkdir, and mkpath functions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 1 | umask 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 1 | ▶ | if ($self->close_all_files) { # Close all fds except the ones we should keep | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | my $openmax = sysconf( &POSIX::_SC_OPEN_MAX ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | ▶ | (not defined $openmax or $openmax < 0) and $openmax = 64; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $openmax or $openmax < 0
MC/DC0%0/2
not defined $openmax or $openmax < 0
not defined $openmax
$openmax < 0
Truth table0%0/3
not(A) or B
A= not defined $openmaxB= $openmax < 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | for (grep { not is_member $_, $self->keep_fhs } 0 .. $openmax) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | POSIX::close( $_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 1 | $self->pidfile->println( $PID ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 17 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 91 | ▶ | my $_ipc_run_harness = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=16.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 91 | my ($self, $cmd_ref, @cmd_args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 91 | ▶ | if ($self->async) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 26 | ▶ | is_coderef $cmd_ref->[ 0 ] and $cmd_ref = $cmd_ref->[ 0 ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 26 | my $pidfile = $self->pidfile; weaken( $pidfile ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | ▶ | my $h = IPC::Run::harness( $cmd_ref, @cmd_args, init => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=2.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | IPC::Run::close_terminal(); $pidfile->println( $PID ) }, '&' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 26 | $h->start; return ( 0, $h ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 65 | my $h = IPC::Run::harness( $cmd_ref, @cmd_args ); $h->run; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 52 | ▶ | my $rv = $h->full_result || 0; $rv =~ m{ unknown }msx and throw $rv; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$h->full_result || 0
MC/DC100%1/1
$h->full_result || 0
$h->full_result
Truth table100%2/2
A
A= $h->full_result
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 52 | return ( $rv, $h ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 17 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 15 | ▶ | my $_new_async_response = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 15 | my ($self, $pid) = @_; my $prog = basename( $self->cmd->[ 0 ] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 15 | $self->log->debug( my $out = "Running ${prog}(${pid}) in the background" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 15 | return $self->response_class->new( out => $out, pid => $pid ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 17 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 12 | ▶ | my $_redirect_child_io = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=14 SCAR=26.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 12 | my ($self, $pipes) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 12 | ▶ | my $in = $self->in || 'null'; my $out = $self->out; my $err = $self->err; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->in || 'null'
MC/DC100%1/1
$self->in || 'null'
$self->in
Truth table100%2/2
A
A= $self->in
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 12 | ▶ | if ($self->async or $self->detach) { $out ||= 'null'; $err ||= 'null' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition85%6/7
$self->async or $self->detach
$out ||= "null"
$err ||= "null"
MC/DC100%2/2
$self->async or $self->detach
$self->async
$self->detach
MC/DC100%1/1
$out ||= "null"
$out
MC/DC0%0/1
$err ||= "null"
$err
Truth table100%3/3
A or B
A= $self->asyncB= $self->detach
Truth table100%2/2
A
A= $out
Truth table50%1/2
A
A= $err
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 12 | ▶ | $in eq 'stdin' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | or $_redirect_stdin-> ( ($in eq 'null') ? devnull | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | : $pipes->[ 0 ]->[ 0 ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 12 | ▶ | $out eq 'stdout' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | or $_redirect_stdout->( ( blessed $out) ? "${out}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | : ($out eq 'null') ? devnull | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | : $pipes->[ 1 ]->[ 1 ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 12 | ▶ | $err eq 'stderr' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | or $_redirect_stderr->( ( blessed $err) ? "${err}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | : ($err eq 'null') ? devnull | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | : $pipes->[ 2 ]->[ 1 ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 12 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 17 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 141 | ▶ | my $_return_codes_or_throw = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=14.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 141 | my ($self, $cmd, $e_num, $e_str) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 141 | ▶ | $e_str ||= 'Unknown error'; chomp $e_str; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$e_str ||= "Unknown error"
MC/DC100%1/1
$e_str ||= "Unknown error"
$e_str
Truth table100%2/2
A
A= $e_str
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 141 | ▶ | if ($e_num == UNDEFINED_RV) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | my $error = 'Program [_1] failed to start: [_2]'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | my $prog = basename( (split SPC, $cmd)[ 0 ] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | throw $error, [ $prog, $e_str ], level => 3, rv => UNDEFINED_RV; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 141 | my $rv = $e_num >> 8; my $core = $e_num & 128; my $sig = $e_num & 127; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 141 | ▶ | if ($rv > $self->expected_rv) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 34 | $self->log->debug( my $error = "${e_str} rv ${rv}" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 34 | throw $error, level => 3, rv => $rv; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 107 | return { core => $core, rv => $rv, sig => $sig, }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 17 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | ▶ | my $_shutdown = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | my $self = shift; my $pidfile = $self->pidfile; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | ▶ | $pidfile->exists and $pidfile->getline == $PID and $self->pidfile->unlink; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$pidfile->exists and $pidfile->getline == $Class::Usul::IPC::Cmd::PID
MC/DC0%0/2
$pidfile->exists and $pidfile->getline == $Class::Usul::IPC::Cmd::PID
$pidfile->exists
$pidfile->getline == $Class::Usul::IPC::Cmd::PID
Truth table0%0/3
A and B
A= $pidfile->existsB= $pidfile->getline == $Class::Usul::IPC::Cmd::PID
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | _exit OK; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 17 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 42 | ▶ | my $_wait_for_pidfile_and_read = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=16.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 42 | my $self = shift; my $pidfile = $self->pidfile; my $waited = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 42 | ▶ | while (not $pidfile->exists or $pidfile->is_empty) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $pidfile->exists or $pidfile->is_empty
MC/DC50%1/2
not $pidfile->exists or $pidfile->is_empty
not $pidfile->exists
$pidfile->is_empty
Truth table66%2/3
not(A) or B
A= not $pidfile->existsB= $pidfile->is_empty
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 668 | nap $self->nap_time; $waited += $self->nap_time; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 668 | ▶ | $waited > $self->max_pidfile_wait | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | and throw 'File [_1] contains no process id', [ $pidfile ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 29 | ▶ | my $pid = $pidfile->chomp->getline || UNDEFINED_RV; $pidfile->close; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$pidfile->chomp->getline || -1
MC/DC0%0/1
$pidfile->chomp->getline || -1
$pidfile->chomp->getline
Truth table50%1/2
A
A= $pidfile->chomp->getline
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 29 | return $pid; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 17 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 0 | ▶ | my $_execute_coderef = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 0 | my $self = shift; my ($code, @args) = @{ $self->cmd }; my $rv; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | ▶ | try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 0 | ▶ | local $SIG{INT} = sub { $self->$_shutdown }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 0 | ▶ | $rv = $code->( $self, @args ); defined $rv and $rv = $rv << 8; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 0 | ▶ | $self->pidfile->exists and $self->pidfile->unlink; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 0 | ▶ | catch { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | ▶ | blessed $_ and $_->can( 'rv' ) and $rv = $_->rv; emit_to \*STDERR, $_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
builtin::blessed($_) and $_->can("rv")
MC/DC0%0/2
builtin::blessed($_) and $_->can("rv")
builtin::blessed($_)
$_->can("rv")
Truth table0%0/3
A and B
A= builtin::blessed($_)B= $_->can("rv")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | ▶ | _exit $rv // OK; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$rv // 0
MC/DC0%0/1
$rv // 0
$rv
Truth table0%0/2
A
A= $rv
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 17 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 69 | ▶ | my $_wait_for_child = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 69 | my ($self, $pid, $pipes) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 69 | my ($filtered, $stderr, $stdout) = (NUL, NUL, NUL); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 69 | my $in_fh = $pipes->[ 0 ]->[ 1 ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 69 | my $out_fh = $pipes->[ 1 ]->[ 0 ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 69 | my $err_fh = $pipes->[ 2 ]->[ 0 ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 69 | my $stat_fh = $pipes->[ 3 ]->[ 0 ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 69 | my $err_hand = $_err_handler->( $self->err, \$filtered, \$stderr ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 69 | my $out_hand = $_out_handler->( $self->out, \$filtered, \$stdout ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 69 | my $prog = basename( my $cmd = $self->cmd->[ 0 ] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 69 | ▶ | try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 69 | ▶ | my $tmout = $self->timeout; $tmout and local $SIG{ALRM} = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 5 | throw TimeOut, [ $prog, $tmout ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 69 | ▶ | } and alarm $tmout; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$tmout and local $SIG{"ALRM"} = sub {
&throw(TimeOut(), [$prog, $tmout]);
}
MC/DC50%1/2
$tmout and local $SIG{"ALRM"} = sub {
&throw(TimeOut(), [$prog, $tmout]);
}
$tmout
local $SIG{"ALRM"} = sub {
&throw(TimeOut(), [$prog, $tmout]);
}
Truth table66%2/3
A and B
A= $tmoutB= local $SIG{"ALRM"} = sub {
&throw(TimeOut(), [$prog, $tmout]);
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 69 | ▶ | my $error = $_recv_exec_failure->( $stat_fh ); $error and throw $error; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 63 | $_send_in->( $in_fh, $self->in ); close $in_fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 63 | $_drain->( $out_fh, $out_hand, $err_fh, $err_hand ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 63 | waitpid $pid, 0; alarm 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 69 | ▶ | catch { alarm 0; throw $_ }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 63 | ▶ | my $e_num = $CHILD_PID > 0 ? $CHILD_ENUM : $CHILD_ERROR; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 63 | my $codes = $self->$_return_codes_or_throw( $cmd, $e_num, $stderr ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | return $self->response_class->new | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | ( core => $codes->{core}, out => $_filter_out->( $filtered ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | rv => $codes->{rv}, sig => $codes->{sig}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 55 | stderr => $stderr, stdout => $stdout ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 17 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 96 | ▶ | my $_run_cmd_using_fork_and_exec = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=6 SCAR=18.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 96 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 96 | my $pipes = $_four_nonblocking_pipe_pairs->(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 96 | my $cmd_str = $_quoted_join->( @{ $self->cmd } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 96 | $self->log->debug( "Running ${cmd_str} using fork and exec" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 96 | { local ($CHILD_ENUM, $CHILD_PID) = (0, 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 96 | ▶ | $self->ignore_zombies and local $SIG{CHLD} = 'IGNORE'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 96 | ▶ | if (my $pid = fork) { # Parent | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 84 | $_close_child_io->( $pipes ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 84 | ▶ | $self->detach and $pid = $self->$_wait_for_pidfile_and_read; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 84 | ▶ | return ($self->async || $self->detach) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->async or $self->detach
MC/DC100%2/2
$self->async or $self->detach
$self->async
$self->detach
Truth table100%3/3
A or B
A= $self->asyncB= $self->detach
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | ? $self->$_new_async_response( $pid ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | : $self->$_wait_for_child( $pid, $pipes ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 12 | ▶ | try { # Child | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=16.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 12 | my $prog = basename( my $cmd = $self->cmd->[ 0 ] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 12 | $self->$_redirect_child_io( $pipes ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 12 | ▶ | $self->detach and $self->$_detach_process; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 12 | ▶ | $self->working_dir and chdir $self->working_dir; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 12 | ▶ | is_coderef $cmd and $self->$_execute_coderef; # Never returns | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 12 | ▶ | exec @{ $self->cmd } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | or throw 'Program [_1] failed to exec: [_2]', [ $prog, $OS_ERROR ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 0 | ▶ | catch { $_send_exec_failure->( $pipes->[ 3 ]->[ 1 ], "${_}" ) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 0 | close $pipes->[ 3 ]->[ 1 ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 0 | return OK; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 17 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 91 | ▶ | my $_run_cmd_using_ipc_run = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=24 SCAR=36.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 91 | my $self = shift; my ($buf_err, $buf_out, $error, $h, $rv) = (NUL, NUL); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 91 | my $cmd = $self->cmd; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 91 | ▶ | my $cmd_ref = $self->partition_cmd ? $_partition_command->( $cmd ) : $cmd; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 91 | my $prog = basename( $cmd->[ 0 ] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 91 | my $null = devnull; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 91 | ▶ | my $in = $self->in || 'null'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->in || 'null'
MC/DC100%1/1
$self->in || 'null'
$self->in
Truth table100%2/2
A
A= $self->in
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 91 | my $out = $self->out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 91 | my $err = $self->err; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 91 | my @cmd_args = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | ▶ | if (blessed $in) { push @cmd_args, "0<${in}" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 78 | elsif ($in eq 'null') { push @cmd_args, "0<${null}" } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 13 | elsif ($in ne 'stdin') { push @cmd_args, '0<', \$in } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 0 | ▶ | if (blessed $out) { push @cmd_args, "1>${out}" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 0 | elsif ($out eq 'null') { push @cmd_args, "1>${null}" } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 91 | elsif ($out ne 'stdout') { push @cmd_args, '1>', \$buf_out } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 0 | ▶ | if (blessed $err) { push @cmd_args, "2>${err}" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 0 | elsif ($err eq 'out') { push @cmd_args, '2>&1' } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 0 | elsif ($err eq 'null') { push @cmd_args, "2>${null}" } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 91 | elsif ($err ne 'stderr') { push @cmd_args, '2>', \$buf_err } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 91 | my $cmd_str = $_quoted_join->( @{ $self->cmd }, @cmd_args ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 91 | ▶ | $self->async and $cmd_str .= ' &'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 91 | $self->log->debug( "Running ${cmd_str} using ipc run" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 91 | ▶ | try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 91 | ▶ | my $tmout = $self->timeout; $tmout and local $SIG{ALRM} = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 13 | throw TimeOut, [ $cmd_str, $tmout ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 91 | ▶ | } and alarm $tmout; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$tmout and local $SIG{"ALRM"} = sub {
&throw(TimeOut(), [$cmd_str, $tmout]);
}
MC/DC50%1/2
$tmout and local $SIG{"ALRM"} = sub {
&throw(TimeOut(), [$cmd_str, $tmout]);
}
$tmout
local $SIG{"ALRM"} = sub {
&throw(TimeOut(), [$cmd_str, $tmout]);
}
Truth table66%2/3
A and B
A= $tmoutB= local $SIG{"ALRM"} = sub {
&throw(TimeOut(), [$cmd_str, $tmout]);
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 91 | ($rv, $h) = $_ipc_run_harness->( $self, $cmd_ref, @cmd_args ); alarm 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 91 | ▶ | catch { alarm 0; throw $_ }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 78 | my $sig = $rv & 127; my $core = $rv & 128; $rv = $rv >> 8; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 78 | ▶ | if ($self->async) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 26 | my $pid = $self->$_wait_for_pidfile_and_read; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 13 | $out = "Started ${prog}(${pid}) in the background"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 13 | return $self->response_class->new | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | ( core => $core, harness => $h, out => $out, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | pid => $pid, rv => $rv, sig => $sig ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 52 | my ($stderr, $stdout) = (NUL, NUL); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 52 | ▶ | if ($out ne 'null' and $out ne 'stdout') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$out ne "null" and $out ne "stdout"
MC/DC0%0/2
$out ne "null" and $out ne "stdout"
$out ne "null"
$out ne "stdout"
Truth table33%1/3
A and B
A= $out ne "null"B= $out ne "stdout"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 52 | ▶ | not blessed $out and $out = $_filter_out->( $stdout = $buf_out ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 0 | else { $out = $stdout = NUL } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 0 | ▶ | if ($err eq 'out') { $stderr = $stdout; $error = $out; chomp $error } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 0 | elsif (blessed $err) { $stderr = $error = $err->all; chomp $error } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | ▶ | elsif ($err ne 'null' and $err ne 'stderr') { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$err ne "null" and $err ne "stderr"
MC/DC0%0/2
$err ne "null" and $err ne "stderr"
$err ne "null"
$err ne "stderr"
Truth table33%1/3
A and B
A= $err ne "null"B= $err ne "stderr"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 52 | $stderr = $error = $buf_err; chomp $error; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | 0 | else { $stderr = $error = NUL } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 52 | ▶ | if ($rv > $self->expected_rv) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 13 | ▶ | $error = $error ? "${error} rv ${rv}" : "Unknown error rv ${rv}"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 13 | $self->log->debug( $error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 13 | throw $error, out => $out, rv => $rv; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 39 | return $self->response_class->new | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | ( core => $core, out => "${out}", rv => $rv, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | sig => $sig, stderr => $stderr, stdout => $stdout ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 17 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 91 | ▶ | my $_run_cmd_using_open3 = sub { # Robbed in part from IPC::Cmd | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 91 | my ($self, $cmd) = @_; my ($filtered, $stderr, $stdout) = (NUL, NUL, NUL); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 91 | my $err_hand = $_err_handler->( $self->err, \$filtered, \$stderr ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 91 | my $out_hand = $_out_handler->( $self->out, \$filtered, \$stdout ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 91 | $self->log->debug( "Running ${cmd} using open3" ); my $e_num; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 91 | { local ($CHILD_ENUM, $CHILD_PID) = (0, 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 91 | ▶ | try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 91 | local $SIG{PIPE} = $_pipe_handler; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 91 | ▶ | my $tmout = $self->timeout; $tmout and local $SIG{ALRM} = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | 13 | throw TimeOut, [ $cmd, $tmout ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 91 | ▶ | } and alarm $tmout; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$tmout and local $SIG{"ALRM"} = sub {
&throw(TimeOut(), [$cmd, $tmout]);
}
MC/DC50%1/2
$tmout and local $SIG{"ALRM"} = sub {
&throw(TimeOut(), [$cmd, $tmout]);
}
$tmout
local $SIG{"ALRM"} = sub {
&throw(TimeOut(), [$cmd, $tmout]);
}
Truth table66%2/3
A and B
A= $tmoutB= local $SIG{"ALRM"} = sub {
&throw(TimeOut(), [$cmd, $tmout]);
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 91 | my ($pid, $in_fh, $out_fh, $err_fh) = $_open3->( $cmd ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 91 | $_send_in->( $in_fh, $self->in ); close $in_fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 91 | $_drain->( $out_fh, $out_hand, $err_fh, $err_hand ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 78 | ▶ | $pid and waitpid $pid, 0; alarm 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 91 | ▶ | catch { alarm 0; throw $_ }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 78 | ▶ | $e_num = $CHILD_PID > 0 ? $CHILD_ENUM : $CHILD_ERROR; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 78 | my $codes = $self->$_return_codes_or_throw( $cmd, $e_num, $stderr ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | return $self->response_class->new | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | ( core => $codes->{core}, out => $_filter_out->( $filtered ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | rv => $codes->{rv}, sig => $codes->{sig}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 52 | stderr => $stderr, stdout => $stdout ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 17 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 78 | ▶ | my $_run_cmd_using_system = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=36 SCAR=41.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | 78 | my ($self, $cmd) = @_; my ($error, $rv); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 78 | my $prog = basename( (split SPC, $cmd)[ 0 ] ); my $null = devnull; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 78 | ▶ | my $in = $self->in || 'stdin'; my $out = $self->out; my $err = $self->err; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->in || 'stdin'
MC/DC100%1/1
$self->in || 'stdin'
$self->in
Truth table100%2/2
A
A= $self->in
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 78 | ▶ | if ($in ne 'null' and $in ne 'stdin' and not blessed $in) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
$in ne "null" and $in ne "stdin" and not builtin::blessed($in)
$in ne "null" and $in ne "stdin"
MC/DC33%1/3
$in ne "null" and $in ne "stdin" and not builtin::blessed($in)
$in ne "null"
$in ne "stdin"
not builtin::blessed($in)
Truth table50%2/4
A and B and not(C)
A= $in ne "null"B= $in ne "stdin"C= not builtin::blessed($in)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | # Different semi-random file names in the temp directory | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 13 | my $tmp = $self->_tempfile; $tmp->print( $in ); $in = $tmp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 78 | ▶ | $out ne 'null' and $out ne 'stdout' and not blessed $out | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$out ne "null" and $out ne "stdout" and not builtin::blessed($out)
$out ne "null" and $out ne "stdout"
MC/DC0%0/3
$out ne "null" and $out ne "stdout" and not builtin::blessed($out)
$out ne "null"
$out ne "stdout"
not builtin::blessed($out)
Truth table25%1/4
A and B and not(C)
A= $out ne "null"B= $out ne "stdout"C= not builtin::blessed($out)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | and $out = $self->_tempfile; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 78 | ▶ | $self->async and $err ||= 'out'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$err ||= "out"
MC/DC0%0/1
$err ||= "out"
$err
Truth table50%1/2
A
A= $err
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 78 | ▶ | $err ne 'null' and $err ne 'stderr' and not blessed $err and $err ne 'out' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition44%4/9
$err ne "null" and $err ne "stderr" and not builtin::blessed($err) and $err ne "out"
$err ne "null" and $err ne "stderr" and not builtin::blessed($err)
$err ne "null" and $err ne "stderr"
MC/DC25%1/4
$err ne "null" and $err ne "stderr" and not builtin::blessed($err) and $err ne "out"
$err ne "null"
$err ne "stderr"
not builtin::blessed($err)
$err ne "out"
Truth table40%2/5
A and B and not(C) and D
A= $err ne "null"B= $err ne "stderr"C= not builtin::blessed($err)D= $err ne "out"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | and $err = $self->_tempfile; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 78 | ▶ | $cmd .= $in eq 'stdin' ? NUL : $in eq 'null' ? " 0<${null}" : " 0<${in}"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | 78 | ▶ | $cmd .= $out eq 'stdout' ? NUL : $out eq 'null' ? " 1>${null}" : " 1>${out}"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | 78 | ▶ | $cmd .= $err eq 'stderr' ? NUL : $err eq 'null' ? " 2>${null}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | : $err ne 'out' ? " 2>${err}" : ' 2>&1'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 78 | ▶ | $self->async and $cmd .= ' & echo $! 1>'.$self->pidfile->pathname; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | 78 | $self->log->debug( "Running ${cmd} using system" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 78 | { local ($CHILD_ENUM, $CHILD_PID) = (0, 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | 78 | ▶ | try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 78 | local $SIG{CHLD} = $_child_handler; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | 78 | ▶ | my $tmout = $self->timeout; $tmout and local $SIG{ALRM} = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | 13 | throw TimeOut, [ $cmd, $tmout ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | 78 | ▶ | } and alarm $tmout; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$tmout and local $SIG{"ALRM"} = sub {
&throw(TimeOut(), [$cmd, $tmout]);
}
MC/DC50%1/2
$tmout and local $SIG{"ALRM"} = sub {
&throw(TimeOut(), [$cmd, $tmout]);
}
$tmout
local $SIG{"ALRM"} = sub {
&throw(TimeOut(), [$cmd, $tmout]);
}
Truth table66%2/3
A and B
A= $tmoutB= local $SIG{"ALRM"} = sub {
&throw(TimeOut(), [$cmd, $tmout]);
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | 78 | $rv = system $cmd; alarm 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | 78 | ▶ | catch { alarm 0; throw $_ }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | 65 | my $os_error = $OS_ERROR; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | 65 | $self->log->debug | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | ( "System rv ${rv} child pid ${CHILD_PID} error ${CHILD_ENUM}" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | # On some systems the child handler reaps the child process so the system | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | # call returns -1 and sets $OS_ERROR to 'No child processes'. This line | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | # and the child handler code fix the problem | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | 65 | ▶ | $rv == UNDEFINED_RV and $CHILD_PID > 0 and $rv = $CHILD_ENUM; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$rv == -1 and $Class::Usul::IPC::Cmd::CHILD_PID > 0
MC/DC0%0/2
$rv == -1 and $Class::Usul::IPC::Cmd::CHILD_PID > 0
$rv == -1
$Class::Usul::IPC::Cmd::CHILD_PID > 0
Truth table33%1/3
A and B
A= $rv == -1B= $Class::Usul::IPC::Cmd::CHILD_PID > 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 65 | ▶ | $rv == UNDEFINED_RV and throw 'Program [_1] failed to start: [_2]', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | [ $prog, $os_error ], rv => $rv; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | 65 | my $sig = $rv & 127; my $core = $rv & 128; $rv = $rv >> 8; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | 65 | my ($stderr, $stdout) = (NUL, NUL); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 65 | ▶ | if ($self->async) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | 13 | ▶ | $rv != 0 and throw 'Program [_1] failed to start', [ $prog ], rv => $rv; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | 13 | my $pid = $self->$_wait_for_pidfile_and_read; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | 13 | $out = "Started ${prog}(${pid}) in the background"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 13 | return $self->response_class->new | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | ( core => $core, out => $out, pid => $pid, rv => $rv, sig => $sig ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | 52 | ▶ | if ($out ne 'stdout' and $out ne 'null' and -f $out) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$out ne "stdout" and $out ne "null" and -f $out
$out ne "stdout" and $out ne "null"
MC/DC0%0/3
$out ne "stdout" and $out ne "null" and -f $out
$out ne "stdout"
$out ne "null"
-f $out
Truth table25%1/4
A and B and C
A= $out ne "stdout"B= $out ne "null"C= -f $out
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 52 | $out = $_filter_out->( $stdout = io( $out )->slurp ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | 0 | else { $out = $stdout = NUL } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | 0 | ▶ | if ($err eq 'out') { $stderr = $stdout; $error = $out; chomp $error } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | ▶ | elsif ($err ne 'stderr' and $err ne 'null' and -f $err) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%2/6
$err ne "stderr" and $err ne "null" and -f $err
$err ne "stderr" and $err ne "null"
MC/DC0%0/3
$err ne "stderr" and $err ne "null" and -f $err
$err ne "stderr"
$err ne "null"
-f $err
Truth table25%1/4
A and B and C
A= $err ne "stderr"B= $err ne "null"C= -f $err
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | 52 | $stderr = $error = io( $err )->slurp; chomp $error; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | 0 | else { $stderr = $error = NUL } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | 52 | ▶ | if ($rv > $self->expected_rv) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | 13 | ▶ | $error = $error ? "${error} rv ${rv}" : "Unknown error rv ${rv}"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | 13 | $self->log->debug( $error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 13 | throw $error, out => $out, rv => $rv; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | 39 | return $self->response_class->new | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | ( core => $core, out => "${out}", rv => $rv, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | sig => $sig, stderr => $stderr, stdout => $stdout ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | 17 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | 356 | ▶ | my $_run_cmd = sub { # Select one of the implementations | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=14 SCAR=30.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | 356 | my $self = shift; my $has_meta = $_has_shell_meta->( my $cmd = $self->cmd ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | 356 | ▶ | if (is_arrayref $cmd) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | 187 | ▶ | $cmd->[ 0 ] or throw Unspecified, [ 'command' ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | 187 | ▶ | (is_win32 or $has_meta or $self->use_ipc_run) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition55%5/9
&is_win32() || $has_meta || $self->use_ipc_run and can_load("modules", {"IPC::Run", "0.84"})
&is_win32() or $has_meta or $self->use_ipc_run
&is_win32() or $has_meta
MC/DC25%1/4
&is_win32() || $has_meta || $self->use_ipc_run and can_load("modules", {"IPC::Run", "0.84"})
&is_win32()
$has_meta
$self->use_ipc_run
can_load("modules", {"IPC::Run", "0.84"})
Truth table28%2/7
A or B or C and D
A= &is_win32()B= $has_metaC= $self->use_ipc_runD= can_load("modules", {"IPC::Run", "0.84"})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | and can_load( modules => { 'IPC::Run' => '0.84' } ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | and return $self->$_run_cmd_using_ipc_run; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | 96 | ▶ | is_win32 or $has_meta or $self->use_system | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
&is_win32() or $has_meta or $self->use_system
&is_win32() or $has_meta
MC/DC0%0/3
&is_win32() or $has_meta or $self->use_system
&is_win32()
$has_meta
$self->use_system
Truth table25%1/4
A or B or C
A= &is_win32()B= $has_metaC= $self->use_system
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | or return $self->$_run_cmd_using_fork_and_exec; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | 0 | $cmd = $_quoted_join->( @{ $cmd } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | 169 | ▶ | not is_win32 and ($has_meta or $self->async or $self->use_system) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition77%7/9
not &is_win32() and $has_meta || $self->async || $self->use_system
$has_meta or $self->async or $self->use_system
$has_meta or $self->async
MC/DC50%2/4
not &is_win32() and $has_meta || $self->async || $self->use_system
not &is_win32()
$has_meta
$self->async
$self->use_system
Truth table60%3/5
not(A) and B or C or D
A= not &is_win32()B= $has_metaC= $self->asyncD= $self->use_system
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | and return $self->$_run_cmd_using_system( $cmd ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | 91 | return $self->$_run_cmd_using_open3( $cmd ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | 17 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | # Construction | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | 356 | ▶ | around 'BUILDARGS' => sub { # Differentiate constructor method signatures | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=7 SCAR=25.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | 356 | ▶ | my ($orig, $self, @args) = @_; my $n = 0; $n++ while (defined $args[ $n ]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | return ( $n == 0) ? {} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | 356 | ▶ | : (is_hashref $args[ 0 ]) ? { %{ $args[ 0 ] } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | : ( $n == 1) ? { cmd => $args[ 0 ] } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | 0 | ▶ | : (is_hashref $args[ 1 ]) ? { cmd => $args[ 0 ], %{ $args[ 1 ] } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | : ( $n % 2 == 1) ? { cmd => @args } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | : { @args }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | 17 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | 356 | ▶ | sub BUILD { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BUILD: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | 356 | $_[ 0 ]->pidfile->chomp->lock; return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | 17 | ▶ | sub import { # Export run_cmd as a function on demand | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
import: called CC=3 SCAR=16.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | 17 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | 0 | ▶ | my $params = { (is_hashref $_[ 0 ]) ? %{+ shift } : () }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | 17 | my @wanted = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | 17 | my $target = caller; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | is_member 'run_cmd', @wanted and install_sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | 0 | ▶ | as => 'run_cmd', into => $target, code => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | 0 | my $cmd = shift; my $attr = arg_list @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | 0 | ▶ | $attr->{cmd} = $cmd or throw Unspecified, [ 'command' ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | 0 | ▶ | $attr->{ $_ } //= $params->{ $_ } for (keys %{ $params }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$attr->{$_} //= $params->{$_}
MC/DC0%0/2
$attr->{$_} //= $params->{$_}
$attr->{$_}
$params->{$_}
Truth table0%0/3
A //= B
A= $attr->{$_}B= $params->{$_}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | 0 | return $_run_cmd->( __PACKAGE__->new( $attr ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | 17 | ▶ | } }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | 17 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | # Public methods | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | 356 | ▶ | sub run_cmd { # Either class or object method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run_cmd: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | 356 | ▶ | return $_run_cmd->( (blessed $_[ 0 ]) ? $_[ 0 ] : __PACKAGE__->new( @_ ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | 17 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||