microsoft / node-pty

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

How to avoid Powershell confirmation(on SIGINT) in windows and stop command execution properly? #454

Closed Askarov5 closed 2 years ago

Askarov5 commented 3 years ago

Environment details

Issue description

Hi everyone. I'm building a cross-platform ElectronJS App by using XtermJS and node-pty. I needed to stop command execution(same as CTRL+C) by clicking on a button. ptyProcess.write('\x03'); worked pretty well in the Unix(MacOS - bash) but in windows(powershell) it showed an error message. So, I changed to ptyProcess.kill('SIGINT') in windows. Looks like it's kinda working but because of the terminate confirmation(Terminate batch job? (Y/N)?) It is not stopping the command execution properly. How can we exit previous command properly and make command line ready to execute the next command?

Here's the part of the code that I used to stop command execution: ipcMain.on('stop-terminal-process', e => { if(os.platform() !== "win32"){ ptyProcess.write('\x03'); } else { ptyProcess.kill('SIGINT'); //ptyProcess.kill('SIGBREAK'); //ptyProcess.write('Y \r'); } })

Note: SIGBREAK did not work too.

Tyriar commented 3 years ago

It's never been clear to be where this message comes from exactly.

Tyriar commented 2 years ago

This message is built into the batch scripting engine (or whatever you would call it). We're working as designed