| 1 | 25 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 2 | 25 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 3 | package POE::Component::Supervisor::Handle::Proc; | ||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||
| 5 | 25 | our $VERSION = '0.09'; | |||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||
| 7 | 25 | ▶ | use MooseX::POE 0.210; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 8 | 25 | ▶ | use POSIX qw(WIFSIGNALED WIFEXITED WEXITSTATUS WTERMSIG); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 9 | 25 | ▶ | use POE::Wheel::Run; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 10 | 25 | ▶ | use Time::HiRes qw(time); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 11 | 25 | ▶ | use Scalar::Util (); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 12 | 25 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||
| 14 | 25 | with qw( | |||||||||||||||||||||||||||||||||||||
| 15 | POE::Component::Supervisor::Handle | ||||||||||||||||||||||||||||||||||||||
| 16 | POE::Component::Supervisor::LogDispatch | ||||||||||||||||||||||||||||||||||||||
| 17 | ); | ||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||
| 19 | has wheel_parameters => ( | ||||||||||||||||||||||||||||||||||||||
| 20 | isa => "HashRef", | ||||||||||||||||||||||||||||||||||||||
| 21 | is => "ro", | ||||||||||||||||||||||||||||||||||||||
| 22 | auto_deref => 1, | ||||||||||||||||||||||||||||||||||||||
| 23 | 642 | ▶ | default => sub { +{ } }, | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 24 | 25 | ); | |||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||
| 26 | 25 | has enable_nested_poe => ( | |||||||||||||||||||||||||||||||||||||
| 27 | isa => "Bool", | ||||||||||||||||||||||||||||||||||||||
| 28 | is => "ro", | ||||||||||||||||||||||||||||||||||||||
| 29 | default => 1, | ||||||||||||||||||||||||||||||||||||||
| 30 | ); | ||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||
| 32 | 25 | has start_nested_poe => ( | |||||||||||||||||||||||||||||||||||||
| 33 | isa => "Bool", | ||||||||||||||||||||||||||||||||||||||
| 34 | is => "ro", | ||||||||||||||||||||||||||||||||||||||
| 35 | default => 1, | ||||||||||||||||||||||||||||||||||||||
| 36 | ); | ||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||
| 38 | 25 | has [map { "std${_}_callback" } qw(out err in)] => ( | |||||||||||||||||||||||||||||||||||||
| 39 | isa => "CodeRef", | ||||||||||||||||||||||||||||||||||||||
| 40 | is => "rw", | ||||||||||||||||||||||||||||||||||||||
| 41 | required => 0, | ||||||||||||||||||||||||||||||||||||||
| 42 | ); | ||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||
| 44 | 25 | has program => ( | |||||||||||||||||||||||||||||||||||||
| 45 | isa => 'ArrayRef|CodeRef', | ||||||||||||||||||||||||||||||||||||||
| 46 | is => "ro", | ||||||||||||||||||||||||||||||||||||||
| 47 | required => 1, | ||||||||||||||||||||||||||||||||||||||
| 48 | ); | ||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||
| 50 | 25 | has until_term => ( | |||||||||||||||||||||||||||||||||||||
| 51 | isa => "Num|Undef", | ||||||||||||||||||||||||||||||||||||||
| 52 | is => "ro", | ||||||||||||||||||||||||||||||||||||||
| 53 | default => 0.1, | ||||||||||||||||||||||||||||||||||||||
| 54 | ); | ||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||
| 56 | 25 | has until_kill => ( | |||||||||||||||||||||||||||||||||||||
| 57 | isa => "Num|Undef", | ||||||||||||||||||||||||||||||||||||||
| 58 | is => "ro", | ||||||||||||||||||||||||||||||||||||||
| 59 | default => 10, | ||||||||||||||||||||||||||||||||||||||
| 60 | ); | ||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||
| 62 | has wait_for => ( | ||||||||||||||||||||||||||||||||||||||
| 63 | isa => "Num|Undef", | ||||||||||||||||||||||||||||||||||||||
| 64 | is => "ro", | ||||||||||||||||||||||||||||||||||||||
| 65 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||
| 66 | predicate => "has_wait_for", | ||||||||||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | default => sub { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||
| 68 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||
| 69 | 0 | ▶ | 5 + ( $self->until_kill || $self->until_term || 0 ); | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
$self->until_kill || $self->until_term || 0
$self->until_kill or $self->until_term
MC/DC0%0/2
$self->until_kill || $self->until_term || 0
$self->until_kill
$self->until_term
Truth table0%0/3
A or B
A= $self->until_killB= $self->until_term
| |||||||||||||||||||||||||||||||||||||||
| 70 | }, | ||||||||||||||||||||||||||||||||||||||
| 71 | 25 | ); | |||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||
| 73 | 25 | has _wheel => ( | |||||||||||||||||||||||||||||||||||||
| 74 | isa => "POE::Wheel::Run", | ||||||||||||||||||||||||||||||||||||||
| 75 | is => "rw", | ||||||||||||||||||||||||||||||||||||||
| 76 | init_arg => undef, | ||||||||||||||||||||||||||||||||||||||
| 77 | clearer => "_clear_wheel", | ||||||||||||||||||||||||||||||||||||||
| 78 | ); | ||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||
| 80 | 25 | has pid => ( | |||||||||||||||||||||||||||||||||||||
| 81 | isa => "Int", | ||||||||||||||||||||||||||||||||||||||
| 82 | is => "ro", | ||||||||||||||||||||||||||||||||||||||
| 83 | init_arg => undef, | ||||||||||||||||||||||||||||||||||||||
| 84 | writer => "_pid", | ||||||||||||||||||||||||||||||||||||||
| 85 | ); | ||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||
| 87 | 25 | has exited => ( | |||||||||||||||||||||||||||||||||||||
| 88 | isa => "Int", | ||||||||||||||||||||||||||||||||||||||
| 89 | is => "rw", | ||||||||||||||||||||||||||||||||||||||
| 90 | init_arg => undef, | ||||||||||||||||||||||||||||||||||||||
| 91 | required => 0, | ||||||||||||||||||||||||||||||||||||||
| 92 | predicate => "has_exited", | ||||||||||||||||||||||||||||||||||||||
| 93 | writer => "_exited", | ||||||||||||||||||||||||||||||||||||||
| 94 | ); | ||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||
| 96 | 25 | has exite_code => ( | |||||||||||||||||||||||||||||||||||||
| 97 | isa => "Int", | ||||||||||||||||||||||||||||||||||||||
| 98 | is => "rw", | ||||||||||||||||||||||||||||||||||||||
| 99 | init_arg => undef, | ||||||||||||||||||||||||||||||||||||||
| 100 | required => 0, | ||||||||||||||||||||||||||||||||||||||
| 101 | predicate => "has_exit_code", | ||||||||||||||||||||||||||||||||||||||
| 102 | writer => "_exit_code", | ||||||||||||||||||||||||||||||||||||||
| 103 | ); | ||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||
| 105 | 25 | has exit_signal => ( | |||||||||||||||||||||||||||||||||||||
| 106 | isa => "Int", | ||||||||||||||||||||||||||||||||||||||
| 107 | is => "rw", | ||||||||||||||||||||||||||||||||||||||
| 108 | init_arg => undef, | ||||||||||||||||||||||||||||||||||||||
| 109 | required => 0, | ||||||||||||||||||||||||||||||||||||||
| 110 | predicate => "has_exit_signal", | ||||||||||||||||||||||||||||||||||||||
| 111 | writer => "_exit_signal", | ||||||||||||||||||||||||||||||||||||||
| 112 | ); | ||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||
| 114 | 1200 | ▶ | sub STOP { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
STOP: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 115 | 1200 | $_[OBJECT]->logger->debug("stopping child handle session $_[SESSION]"); | |||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||
| 118 | 1142 | ▶ | sub START { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
START: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 119 | 1142 | my ( $self, $kernel ) = @_[OBJECT, KERNEL]; | |||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||
| 121 | 1142 | $kernel->refcount_increment( $self->get_session_id, __PACKAGE__ ); | |||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||
| 123 | 1142 | my $program = $self->_wrapped_program; | |||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||
| 125 | 1142 | my $wheel = POE::Wheel::Run->new( | |||||||||||||||||||||||||||||||||||||
| 126 | StderrEvent => "stderr", | ||||||||||||||||||||||||||||||||||||||
| 127 | StdoutEvent => "stdout", | ||||||||||||||||||||||||||||||||||||||
| 128 | StdinEvent => "stdin", | ||||||||||||||||||||||||||||||||||||||
| 129 | $self->wheel_parameters, | ||||||||||||||||||||||||||||||||||||||
| 130 | Program => $program, | ||||||||||||||||||||||||||||||||||||||
| 131 | ); | ||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||
| 133 | 1121 | my $pid = $wheel->PID; | |||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||
| 135 | 1121 | $self->_wheel($wheel); | |||||||||||||||||||||||||||||||||||||
| 136 | 1121 | $self->_pid($pid); | |||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||
| 138 | 1121 | $self->notify_spawn( pid => $pid ); | |||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||
| 140 | 1121 | $kernel->sig_child( $wheel->PID, "child_exit" ); | |||||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||
| 143 | 1142 | ▶ | sub _wrapped_program { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_wrapped_program: called CC=4 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||
| 144 | 1142 | my ( $self, $program ) = @_; | |||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||
| 146 | 1142 | ▶ | $program ||= $self->program; | ||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$program ||= $self->program
MC/DC0%0/2
$program ||= $self->program
$program
$self->program
Truth table33%1/3
A ||= B
A= $programB= $self->program
| |||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||
| 148 | 1142 | ▶ | if ( ref($program) eq 'CODE' ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 149 | 1142 | ▶ | if ( $self->enable_nested_poe ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 150 | 1142 | my $also_start = $self->start_nested_poe; | |||||||||||||||||||||||||||||||||||||
| 151 | 21 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=9.2
| |||||||||||||||||||||||||||||||||||||||
| 152 | 21 | my @args = @_; | |||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||
| 154 | 21 | $poe_kernel->stop; | |||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||
| 156 | 21 | $program->(@args); | |||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||
| 158 | 0 | ▶ | $poe_kernel->run if $also_start; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 159 | }, | ||||||||||||||||||||||||||||||||||||||
| 160 | 1142 | } | |||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||
| 163 | 0 | return $program; | |||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||
| 166 | 25 | foreach my $event (qw(stdout stderr stdin)) { | |||||||||||||||||||||||||||||||||||||
| 167 | 75 | my $cb_name = "${event}_callback"; | |||||||||||||||||||||||||||||||||||||
| 168 | 498 | ▶ | event $event => sub { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
stdin: called CC=2 SCAR=7.0
Subroutine
stdout: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||
| 169 | 498 | ▶ | if ( my $cb = $_[OBJECT]->$cb_name ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||
| 170 | 498 | $cb->(@_); | |||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||
| 172 | 75 | }; | |||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||
| 175 | 398 | ▶ | event child_exit => sub { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||
| 176 | 398 | my ( $self, $exit ) = @_[OBJECT, ARG2]; | |||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||
| 178 | 398 | ▶ | my $exit_code = WIFEXITED($exit) ? WEXITSTATUS($exit) : undef; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 179 | 398 | ▶ | my $exit_signal = WIFSIGNALED($exit) ? WTERMSIG($exit) : undef; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||
| 181 | 398 | $self->_exited($exit); | |||||||||||||||||||||||||||||||||||||
| 182 | 398 | ▶ | $self->_exit_code($exit_code) if defined $exit_code; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 183 | 398 | ▶ | $self->_exit_signal($exit_signal) if defined($exit_signal); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||
| 185 | 398 | ▶ | $self->logger->info("child exited with status " . ($exit_code || "undef") . " ($exit), notifying supervisor"); | ||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$exit_code || 'undef'
MC/DC100%1/1
$exit_code || 'undef'
$exit_code
Truth table100%2/2
A
A= $exit_code
| |||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||
| 187 | 398 | $self->notify_stop( | |||||||||||||||||||||||||||||||||||||
| 188 | pid => $self->pid, | ||||||||||||||||||||||||||||||||||||||
| 189 | exit => $exit, | ||||||||||||||||||||||||||||||||||||||
| 190 | exit_code => $exit_code, | ||||||||||||||||||||||||||||||||||||||
| 191 | exit_signal => $exit_signal, | ||||||||||||||||||||||||||||||||||||||
| 192 | ); | ||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||
| 194 | 398 | $self->call("_cleanup"); | |||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||
| 196 | 25 | }; | |||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||
| 198 | 1067 | ▶ | event _cleanup => sub { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_cleanup: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||
| 199 | 1067 | my ( $self, $kernel ) = @_[OBJECT, KERNEL]; | |||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||
| 201 | 1067 | ▶ | if ( my $wheel = $self->_wheel ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||
| 202 | 1067 | $wheel->shutdown_stdin; | |||||||||||||||||||||||||||||||||||||
| 203 | 1067 | $self->_clear_wheel; | |||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||
| 206 | 1067 | $kernel->alarm_remove_all(); | |||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||
| 208 | 1067 | $kernel->refcount_decrement( $self->get_session_id, __PACKAGE__ ); | |||||||||||||||||||||||||||||||||||||
| 209 | 25 | }; | |||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||
| 211 | 950 | ▶ | sub stop { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
stop: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 212 | 950 | my $self = shift; | |||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||
| 214 | 950 | $self->call("_stop_child"); | |||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||
| 217 | 950 | ▶ | event _stop_child => sub { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=8 SCAR=23.4
| |||||||||||||||||||||||||||||||||||||||
| 218 | 950 | my ( $self, $kernel, $heap ) = @_[OBJECT, KERNEL, HEAP]; | |||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||
| 220 | 950 | $self->call("_close_stdin"); | |||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||
| 222 | 950 | my $now = time; | |||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||
| 224 | 950 | my ( $until_term, $until_kill ) = ( $self->until_term, $self->until_kill ); | |||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||
| 226 | 950 | ▶ | my $start_term = defined($until_term) && $now + $until_term; | ||||||||||||||||||||||||||||||||||||
|
Condition50%3/6
defined $until_term && $now + $until_term
defined $until_term && $now + $until_term
MC/DC0%0/2
defined $until_term && $now + $until_term
defined $until_term
$now + $until_term
MC/DC0%0/2
defined $until_term && $now + $until_term
defined $until_term
$now + $until_term
Truth table33%1/3
A && B
A= defined $until_termB= $now + $until_term
Truth table0%0/3
A && B
A= defined $until_termB= $now + $until_term
| |||||||||||||||||||||||||||||||||||||||
| 227 | 950 | ▶ | my $start_kill = defined($until_kill) && $now + $until_kill; | ||||||||||||||||||||||||||||||||||||
|
Condition50%3/6
defined $until_kill && $now + $until_kill
defined $until_kill && $now + $until_kill
MC/DC0%0/2
defined $until_kill && $now + $until_kill
defined $until_kill
$now + $until_kill
MC/DC0%0/2
defined $until_kill && $now + $until_kill
defined $until_kill
$now + $until_kill
Truth table33%1/3
A && B
A= defined $until_killB= $now + $until_kill
Truth table0%0/3
A && B
A= defined $until_killB= $now + $until_kill
| |||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||
| 229 | 950 | ▶ | my $give_up = $self->has_wait_for && $now + $self->wait_for; | ||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->has_wait_for && $now + $self->wait_for
MC/DC0%0/2
$self->has_wait_for && $now + $self->wait_for
$self->has_wait_for
$now + $self->wait_for
Truth table33%1/3
A && B
A= $self->has_wait_forB= $now + $self->wait_for
| |||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||
| 231 | 950 | ▶ | $kernel->alarm_set( _term_loop => $start_term, $start_kill || $give_up ) if $start_term; | ||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
$start_kill || $give_up
MC/DC0%0/2
$start_kill || $give_up
$start_kill
$give_up
Truth table33%1/3
A || B
A= $start_killB= $give_up
| |||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||
| 233 | 950 | ▶ | $kernel->alarm_set( _kill_loop => $start_kill, $give_up ) if $start_kill; | ||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||
| 235 | 950 | ▶ | $kernel->alarm_set( _couldnt_kill => $give_up ) if $give_up; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 236 | 25 | }; | |||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||
| 238 | 950 | ▶ | event _close_stdin => sub { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_close_stdin: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||
| 239 | 950 | my ( $self, $kernel ) = @_[OBJECT, KERNEL]; | |||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||
| 241 | 950 | $self->logger->info("closing child stdin"); | |||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||
| 243 | 950 | ▶ | if ( my $wheel = $self->_wheel ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 244 | 883 | $wheel->shutdown_stdin; | |||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||
| 246 | 25 | }; | |||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||
| 248 | 25 | foreach my $sig (qw(term kill)) { | |||||||||||||||||||||||||||||||||||||
| 249 | 50 | my $SIG = uc($sig); | |||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||
| 251 | 50 | my $event = "_${sig}_loop"; | |||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||
| 253 | 652 | ▶ | event $event => sub { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_term_loop: called CC=5 SCAR=17.8
| |||||||||||||||||||||||||||||||||||||||
| 254 | 652 | my ( $self, $kernel, $until, $iter ) = @_[OBJECT, KERNEL, ARG0 .. $#_]; | |||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||
| 256 | 652 | ▶ | $iter ||= 0; | ||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$iter ||= 0
MC/DC0%0/1
$iter ||= 0
$iter
Truth table50%1/2
A
A= $iter
| |||||||||||||||||||||||||||||||||||||||
| 257 | 652 | my $delay = 2 ** $iter / 10; # exponential back off | |||||||||||||||||||||||||||||||||||||
| 258 | 652 | my $next_attempt = time() + $delay; | |||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||
| 260 | 652 | ▶ | if ( !defined($until) or $next_attempt < $until ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not defined $until or $next_attempt < $until
MC/DC0%0/2
not defined $until or $next_attempt < $until
not defined $until
$next_attempt < $until
Truth table33%1/3
not(A) or B
A= not defined $untilB= $next_attempt < $until
| |||||||||||||||||||||||||||||||||||||||
| 261 | 652 | $kernel->alarm_set( $event, $next_attempt, $until, $iter + 1 ); | |||||||||||||||||||||||||||||||||||||
| 262 | } else { | ||||||||||||||||||||||||||||||||||||||
| 263 | 0 | undef $delay; | |||||||||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||
| 266 | 652 | ▶ | $self->logger->info("sending SIG$SIG, attempt #" . ( $iter + 1) . ( $delay ? ", next attempt in $delay" : " (last attempt)" )); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||
| 268 | 652 | $self->_wheel->kill($SIG); | |||||||||||||||||||||||||||||||||||||
| 269 | 50 | }; | |||||||||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||
| 272 | 0 | ▶ | event _couldnt_kill => sub { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_couldnt_kill: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||
| 273 | 0 | die "couldn't kill child"; | |||||||||||||||||||||||||||||||||||||
| 274 | 25 | }; | |||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||
| 276 | 0 | ▶ | sub is_running { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
is_running: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 277 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||
| 278 | 0 | not $self->has_exited; | |||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||
| 281 | 25 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||
| 283 | __END__ | ||||||||||||||||||||||||||||||||||||||