From be733ccdd35209d575c211cf97bec0912e6523a7 Mon Sep 17 00:00:00 2001 From: Niklas Keller Date: Tue, 19 Sep 2017 20:16:06 +0200 Subject: [PATCH] Cancel child PID watcher on destroy and close sockets before proc_close --- lib/Internal/Windows/Runner.php | 5 +++++ lib/Internal/Windows/SocketConnector.php | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/Internal/Windows/Runner.php b/lib/Internal/Windows/Runner.php index 319c671..e278e61 100644 --- a/lib/Internal/Windows/Runner.php +++ b/lib/Internal/Windows/Runner.php @@ -152,6 +152,11 @@ public function destroy(ProcessHandle $handle) { } } + if ($handle->childPidWatcher !== null) { + Loop::cancel($handle->childPidWatcher); + $handle->childPidWatcher = null; + } + if ($handle->exitCodeWatcher !== null) { Loop::cancel($handle->exitCodeWatcher); $handle->exitCodeWatcher = null; diff --git a/lib/Internal/Windows/SocketConnector.php b/lib/Internal/Windows/SocketConnector.php index 507893a..6700058 100644 --- a/lib/Internal/Windows/SocketConnector.php +++ b/lib/Internal/Windows/SocketConnector.php @@ -311,8 +311,6 @@ public function onProcessConnectTimeout($watcher, Handle $handle) { } $error = $error ?: 'Process did not connect to server before timeout elapsed'; - \fclose($handle->wrapperStderrPipe); - \proc_close($handle->proc); foreach ($handle->sockets as $socket) { \fclose($socket); } @@ -322,6 +320,9 @@ public function onProcessConnectTimeout($watcher, Handle $handle) { $deferred->fail($error); } + \fclose($handle->wrapperStderrPipe); + \proc_close($handle->proc); + $handle->joinDeferred->fail($error); }