Skip to content

Commit

Permalink
Cancel child PID watcher on destroy and close sockets before proc_close
Browse files Browse the repository at this point in the history
  • Loading branch information
kelunik committed Sep 19, 2017
1 parent 6c5eba0 commit be733cc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions lib/Internal/Windows/Runner.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions lib/Internal/Windows/SocketConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -322,6 +320,9 @@ public function onProcessConnectTimeout($watcher, Handle $handle) {
$deferred->fail($error);
}

\fclose($handle->wrapperStderrPipe);
\proc_close($handle->proc);

$handle->joinDeferred->fail($error);
}

Expand Down

0 comments on commit be733cc

Please sign in to comment.