microsoft / node-pty

Fork pseudoterminals in Node.JS
Other
1.46k stars 235 forks source link

[QUESTION] How do you kill a spawned node-pty process and respawn a new process? #474

Closed jackson-sandland closed 3 years ago

jackson-sandland commented 3 years ago

Environment details

Issue description

I am able to spawn a node process. I'm able to kill the process using the message listener. What I would like to do is respawn the node-pty process with a python process when a websocket sends a specific message from the UI. What is the best pattern to use when destroying a node-pty process and then respawning a new node-pty process?

Tyriar commented 3 years ago

The way VS Code does this is it has a IShellLaunchConfig interface which holds all information required to launch it:

https://github.com/microsoft/vscode/blob/2fc3214ba42050459096e5731513833efd4ac270/src/vs/platform/terminal/common/terminal.ts#L204

Then it has a relaunch function which uses it:

https://github.com/microsoft/vscode/blob/2fc3214ba42050459096e5731513833efd4ac270/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts#L1323-L1326