1
0
mirror of https://github.com/danog/process.git synced 2024-11-26 20:24:43 +01:00

Check status before failing join deferred

This commit is contained in:
Aaron Piotrowski 2017-12-06 17:37:08 -06:00
parent 04a4c8cea2
commit 8f837b3f94
No known key found for this signature in database
GPG Key ID: ADD1EF783EDE9EEB

View File

@ -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 */