Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #484 from Leont/exit-status
Pass correct exitstatus and signal values from Proc::Async to Proc
  • Loading branch information
FROGGS committed Jul 29, 2015
2 parents f7cdcd9 + fa71870 commit c27dc53
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/core/Proc.pm
Expand Up @@ -13,7 +13,7 @@ my class Proc {

submethod BUILD(:$in = '-', :$out = '-', :$err = '-', :$exitcode,
Bool :$bin, Bool :$chomp = True, Bool :$merge,
Str:D :$enc = 'utf8', Str:D :$nl = "\n") {
Str:D :$enc = 'utf8', Str:D :$nl = "\n", :$signal) {
if nqp::istype($in, IO::Handle) && $in.DEFINITE {
$!in_fh := nqp::getattr(nqp::decont($in), IO::Handle, '$!PIO');
$!flags += nqp::const::PIPE_INHERIT_IN;
Expand Down Expand Up @@ -85,6 +85,9 @@ my class Proc {
if nqp::istype($exitcode, Int) && $exitcode.DEFINITE {
$!exitcode = $exitcode;
}
if nqp::istype($signal, Int) && $signal.DEFINITE {
$!signal = $signal;
}
}

method spawn(*@args ($, *@), :$cwd = $*CWD, :$env) {
Expand Down
2 changes: 1 addition & 1 deletion src/core/Proc/Async.pm
Expand Up @@ -172,7 +172,7 @@ my class Proc::Async {

my Mu $callbacks := nqp::hash();
nqp::bindkey($callbacks, 'done', -> Mu \status {
$!exit_promise.keep(Proc.new(:exitcode(status)))
$!exit_promise.keep(Proc.new(:exitcode(status +> 8), :signal(status +& 0xFF)))
});
nqp::bindkey($callbacks, 'error', -> Mu \err {
$!exit_promise.break(X::OS.new(os-error => err));
Expand Down

0 comments on commit c27dc53

Please sign in to comment.