diff --git a/src/win/conpty.cc b/src/win/conpty.cc index 6f36a0d2..f614cc4a 100644 --- a/src/win/conpty.cc +++ b/src/win/conpty.cc @@ -257,6 +257,13 @@ static void OnProcessExit(uv_async_t *async) { DWORD exitCode = 0; GetExitCodeProcess(baton->hShell, &exitCode); + // Clean up handles + // Calling DisconnectNamedPipes here or in PtyKill results in a crash, + // ref https://github.com/microsoft/node-pty/issues/512, + // so we only call CloseHandle for now. + CloseHandle(baton->hIn); + CloseHandle(baton->hOut); + // Call function v8::Local args[1] = { Nan::New(exitCode) @@ -476,10 +483,6 @@ static NAN_METHOD(PtyKill) { } } - DisconnectNamedPipe(handle->hIn); - DisconnectNamedPipe(handle->hOut); - CloseHandle(handle->hIn); - CloseHandle(handle->hOut); CloseHandle(handle->hShell); }