From 8f837b3f94607995e90fdda6037796aab8df8b62 Mon Sep 17 00:00:00 2001 From: Aaron Piotrowski Date: Wed, 6 Dec 2017 17:37:08 -0600 Subject: [PATCH] Check status before failing join deferred --- lib/Internal/Posix/Runner.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/Internal/Posix/Runner.php b/lib/Internal/Posix/Runner.php index 030940c..e666785 100644 --- a/lib/Internal/Posix/Runner.php +++ b/lib/Internal/Posix/Runner.php @@ -47,11 +47,14 @@ final class Runner implements ProcessRunner { if (!$pid || !\is_numeric($pid)) { $error = new ProcessException("Could not determine PID"); $handle->pidDeferred->fail($error); - $handle->joinDeferred->fail($error); foreach ($deferreds as $deferred) { /** @var $deferred Deferred */ $deferred->fail($error); } + if ($handle->status < ProcessStatus::ENDED) { + $handle->status = ProcessStatus::ENDED; + $handle->joinDeferred->fail($error); + } return; } @@ -148,8 +151,10 @@ final class Runner implements ProcessRunner { throw new ProcessException("Terminating process failed"); } - $handle->status = ProcessStatus::ENDED; - $handle->joinDeferred->fail(new ProcessException("The process was killed")); + if ($handle->status < ProcessStatus::ENDED) { + $handle->status = ProcessStatus::ENDED; + $handle->joinDeferred->fail(new ProcessException("The process was killed")); + } } /** @inheritdoc */