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

Fix loop hanging if process is killed during handshake on Windows

This commit is contained in:
Niklas Keller 2017-09-19 19:41:01 +02:00 committed by Aaron Piotrowski
parent df827c767e
commit f7d6288d21
No known key found for this signature in database
GPG Key ID: ADD1EF783EDE9EEB
2 changed files with 7 additions and 3 deletions

View File

@ -35,6 +35,9 @@ final class Handle extends ProcessHandle {
/** @var Deferred[] */
public $stdioDeferreds;
/** @var string */
public $childPidWatcher;
/** @var string */
public $connectTimeoutWatcher;

View File

@ -97,7 +97,6 @@ final class SocketConnector {
$state->receivedDataBuffer = '';
Loop::cancel($state->readWatcher);
Loop::cancel($state->timeoutWatcher);
return $data;
}
@ -179,6 +178,8 @@ final class SocketConnector {
return;
}
Loop::cancel($pendingClient->timeoutWatcher);
unset($this->pendingClients[$socketId]);
$handle = $this->pendingProcesses[$pendingClient->pid];
@ -195,7 +196,7 @@ final class SocketConnector {
$handle->sockets[$pendingClient->streamId] = $socket;
if (count($handle->sockets) === 3) {
$pendingClient->readWatcher = Loop::onReadable($handle->sockets[0], [$this, 'onReadableChildPid'], $handle);
$handle->childPidWatcher = Loop::onReadable($handle->sockets[0], [$this, 'onReadableChildPid'], $handle);
$handle->stdioDeferreds[0]->resolve(new ResourceOutputStream($handle->sockets[0]));
$handle->stdioDeferreds[1]->resolve(new ResourceInputStream($handle->sockets[1]));
$handle->stdioDeferreds[2]->resolve(new ResourceInputStream($handle->sockets[2]));
@ -209,7 +210,7 @@ final class SocketConnector {
return;
}
Loop::cancel($watcher);
Loop::cancel($handle->childPidWatcher);
Loop::cancel($handle->connectTimeoutWatcher);
if (\strlen($data) !== 5) {