Skip to content
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

Starting and terminating erl.exe under powershell "corrupts" it #9285

Closed
josevalim opened this issue Jan 13, 2025 · 2 comments
Closed

Starting and terminating erl.exe under powershell "corrupts" it #9285

josevalim opened this issue Jan 13, 2025 · 2 comments
Assignees
Labels
bug Issue is reported as a bug team:VM Assigned to OTP team VM

Comments

@josevalim
Copy link
Contributor

Describe the bug

Create this file, called proc.ps1:

$output = Start-Process -FilePath "erl.exe" -NoNewWindow -Wait -PassThru
exit $output.ExitCode

Now invoke proc.ps1 inside Powershell on Windows and it should start the Erlang shell. However, if you press Ctrl+C, it quits Erlang but leaves the shell in a weird state where Ctrl+C and similar do not work anymore.

Affected versions

I can reproduce it on 27.2. I am honestly not sure if this is an Erlang bug or not, maybe it is PowerShell doing weird things, but since I got a minimal reproduction I thought I would report it upstream. It was originally reported here: elixir-lang/elixir#14174

@frazze-jobb
Copy link
Contributor

I was able to replicate this on Windows 10, and with a different behavior on Windows 11. We are handling Ctrl+C correctly by returning TRUE in the interrupt handler. But PowerShell "StartProcess -NoNewWindow -Wait" mode seems to also get the Ctrl+C signal, which causes it to print the prompt and somehow hijack the input. If I type slowly, inputted characters are mostly read by Powershell. If I type fast then some characters are read by erl.exe. If I type "exit" slowly I can exit the PowerShell session and continue with the erl.exe session.

On Windows 11, If I type Ctrl+C then the PowerShell session prints its prompt and then exits. So the erl.exe session is still in a usable state.

I reported a bug on PowerShell through feedback hub on windows.

@max-au
Copy link
Contributor

max-au commented Jan 27, 2025

Leaving it here if anyone stumbles over this and just needs a temporary fix:

(Blindly) typing stty sane and pressing Enter will recover powershell terminal to be usable again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue is reported as a bug team:VM Assigned to OTP team VM
Projects
None yet
Development

No branches or pull requests

4 participants