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

Fix hanging if process is destroyed during startup

This commit is contained in:
Niklas Keller 2017-09-20 10:32:13 +02:00 committed by Aaron Piotrowski
parent a9f60b8d89
commit 96491ebfe1
No known key found for this signature in database
GPG Key ID: ADD1EF783EDE9EEB

View File

@ -229,12 +229,16 @@ final class SocketConnector {
return;
}
$handle->status = ProcessStatus::RUNNING;
$handle->pidDeferred->resolve($packet['pid']);
$handle->exitCodeWatcher = Loop::onReadable($handle->sockets[0], [$this, 'onReadableExitCode'], $handle);
if (!$handle->exitCodeRequested) {
Loop::unreference($handle->exitCodeWatcher);
// Required, because a process might be destroyed while starting
if ($handle->status === ProcessStatus::STARTING) {
$handle->status = ProcessStatus::RUNNING;
$handle->exitCodeWatcher = Loop::onReadable($handle->sockets[0], [$this, 'onReadableExitCode'], $handle);
if (!$handle->exitCodeRequested) {
Loop::unreference($handle->exitCodeWatcher);
}
}
unset($this->pendingProcesses[$handle->wrapperPid]);