X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMooseX%2FRunnable%2FInvocation%2FPlugin%2FRestart%2FBase.pm;h=1802a0caf7e61d2d23eb7fa9892ab3b0c52b5e9b;hb=7bd2975e68a94679faf0c68af07203206a5c006b;hp=9d516dbfdb0fbea721036fa0cfe57e3ea4113e84;hpb=a496e4e50c505bab75dbc1e8e47324a7901bf9dc;p=gitmo%2FMooseX-Runnable.git diff --git a/lib/MooseX/Runnable/Invocation/Plugin/Restart/Base.pm b/lib/MooseX/Runnable/Invocation/Plugin/Restart/Base.pm index 9d516db..1802a0c 100644 --- a/lib/MooseX/Runnable/Invocation/Plugin/Restart/Base.pm +++ b/lib/MooseX/Runnable/Invocation/Plugin/Restart/Base.pm @@ -44,6 +44,14 @@ around 'run' => sub { # handle the case where the child dies unexpectedly waitpid $self->child_pid, 0; $self->clear_child_pid; + my ($code, $sig) = ($? >> 8, $? & 127); + eval { $self->_debug_message( + "Exiting early, child died with status $code (signal $sig).", + )}; + + # relay the error up, so the shell (etc.) can see it + kill $sig, $$ if $sig; # no-op? + exit $code; }; # parent @@ -71,12 +79,20 @@ around 'run' => sub { kill 'KILL', $pid2; }; waitpid $pid2, 0; - $child_body->(); + my $code = $? >> 8; + if($code == 0){ + goto $child_body; + } + else { + eval { $self->_debug_message( + "Child exited with non-zero status; aborting.", + )}; + exit $code; + } } else { # child? actually do the work exit $self->$next(@args); - } } };