-
Notifications
You must be signed in to change notification settings - Fork 252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to kill pty process on Windows #437
Comments
I can reproduce, not sure why this happens but you can always use process.exit() to workaround it. |
In the example I could use |
Ok, well this is up for grabs if someone wants to look into it. The likely culprit is either the process does not get killed correctly or something in windowsTerminal.ts or windowsPtyAgent.ts is not being released, preventing node from shutting down. |
@Tyriar Does |
@jerch I tried to kill the pty process with |
@jerch VS Code actually does that but only because I get reports about sometimes process trees not getting killed correctly, I'm pretty sure in the majority of cases |
@t1m0thyj Cannot tell that for sure, imho @Tyriar Ah ic, well if a kill subprocess gets the job done without segfaulting then it might be valid workaround for those corner cases. If really a dangling resource is the culprit (a forgotten handle in the C++ code), then it might provoke a segfault after an outer force-kill, just with the next access attempt by libuv (or any C++ code that still tries to access it). |
@jerch Killing the process via an external command doesn't help: require('child_process').exec(`taskkill /pid ${ptyProcess.pid} /T /F`); I've also tried running |
@t1m0thyj Then it is most likely some dangling resource in the C++ part, as @Tyriar already mentioned. You can try to call |
happening on linux too microsoft/vscode#94877 |
I'm unable to set this project up locally to debug this (can there be a contribution guide for building on Windows?), but if it's helpful, I used # PIPEWRAP
D:\a\node_modules\node-pty\lib\windowsPtyAgent.js:97 - this._inSocket = new net_1.Socket({
D:\a\node_modules\node-pty\lib\windowsTerminal.js:50 - _this._agent = new windowsPtyAgent_1.WindowsPtyAgent(file, args, parsedEnv, cwd, _this._cols, _this._rows, false, opt.useConpty, opt.conptyInheritCursor);
D:\a\node_modules\node-pty\lib\index.js:28 - return new terminalCtor(file, args, opt);
# PIPEWRAP
D:\a\node_modules\node-pty\lib\windowsPtyAgent.js:240 - this._outSocket.destroy();
# Timeout
D:\a\node_modules\node-pty\lib\eventEmitter2.js:40 - queue[i].call(undefined, data);
D:\a\node_modules\node-pty\lib\terminal.js:86 - this.on('exit', function (exitCode, signal) { return _this._onExit.fire({ exitCode: exitCode, signal: signal }); }); Looks like an open socket and a |
Any update for killing the node-pty process? |
The `useConpty` spawn option can be used to disable ConPTY usage until microsoft/node-pty#437 is resolved.
Environment details
Issue description
Using the simple example script below, I am unable to kill the pty process on Windows 10. However, I can successfully kill the pty process on Ubuntu with the same script and identical versions of Node.js and node-pty.
Test Script
Based on https://github.com/microsoft/node-pty/blob/master/examples/killDeepTree/index.js
Output on Windows
The script hangs on the line "Killing pty" and never returns.
Output on Ubuntu
The script finishes and returns to a prompt in the original directory.
The text was updated successfully, but these errors were encountered: