Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Make sure we .quit only if we're completely ready
  • Loading branch information
lizmat committed Sep 17, 2014
1 parent 20193d2 commit 8d45e69
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/core/Proc/Async.pm
Expand Up @@ -112,11 +112,10 @@ my class Proc::Async {
std ~ ( type ?? '_chars' !! '_bytes' ),
-> Mu \seq, Mu \data, Mu \err {
if err {
$promise.break;
supply.quit(err);
$promise.keep( (supply,err) );
}
elsif seq < 0 {
$promise.keep;
$promise.keep( supply );
}
else {
#say "{std}: seq = {seq} with {data} in {$*THREAD}" if std eq 'stdout';
Expand Down Expand Up @@ -170,8 +169,12 @@ my class Proc::Async {
$args-without, $*CWD.Str, $hash-without, $callbacks);

Promise.allof( $!exit_promise, @!promises ).then( {
$!stdout_supply.done if $!stdout_supply;
$!stderr_supply.done if $!stderr_supply;
for @!promises -> $promise {
given $promise.result {
when Supply { .done }
when Parcel { $_[0].quit( $_[1] ) }
}
}
$!exit_promise.result;
} );
}
Expand Down

0 comments on commit 8d45e69

Please sign in to comment.