Skip to content

Commit

Permalink
Prevent silencing ExitFailure in ProcessContext->join()
Browse files Browse the repository at this point in the history
If there was an ExitSuccess, it's expected to be 0. If no failure was present, then the exit code is the only thing to be reported.

But, if there was an ExitFailure, and the process did not cleanly exit, the failure most likely was the cause of the unclean exit and should be reported in any case.
  • Loading branch information
bwoebi authored Dec 20, 2024
1 parent 9777db1 commit 4592406
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Context/ProcessContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Amp\ByteStream\WritableResourceStream;
use Amp\Cancellation;
use Amp\Parallel\Context\Internal\AbstractContext;
use Amp\Parallel\Context\Internal\ExitFailure;
use Amp\Parallel\Ipc\IpcHub;
use Amp\Process\Process;
use Amp\Process\ProcessException;
Expand Down Expand Up @@ -281,7 +282,7 @@ public function join(?Cancellation $cancellation = null): mixed
$data = $this->receiveExitResult($cancellation);

$code = $this->process->join();
if ($code !== 0) {
if ($code !== 0 && !($data instanceof ExitFailure)) {
throw new ContextException(\sprintf("Context exited with code %d", $code));
}

Expand Down

0 comments on commit 4592406

Please sign in to comment.