Pressing Ctrl-C while executing a command in PowerShell Core closes tab
analogrelay opened this issue · 4 comments
For some reason, when using PowerShell Core (pwsh.exe
) in FluentTerminal, pressing Ctrl-C during a long-running command closes the entire tab.
- This does not repro if I'm just sitting at a blank command prompt (no active PowerShell command)
- This does not repro in
pwsh.exe
outside of FluentTerminal - This does not repro in
powershell.exe
(non-Core PowerShell) inside FluentTerminal
Here's a recording illustrating what I mean (using the on-screen keyboard to illustrate when Ctrl-C is pressed)
It's odd that this only happens in pwsh.exe
, perhaps there is some interaction between PowerShell Core and the console APIs that isn't properly handled here.
Let me know if I can help repro anything or get any more data! I'm a big fan of FluentTerminal so far, looking forward to seeing it develop!
What version of pwsh are you using? I just tried the exact same with 6.1.3 but was not able to reproduce this in Fluent Terminal 0.3.1 or current master.
It's 6.1.3 for me too. It's very possible it's something on my machine. Let me see if I can get a crash dump or something with more information.
I figured it out! It's not FluentTerminal :). I also use "scoop" (a package manager for Windows) that creates shim exes for the programs that are installed. The issue only reproduces if that shim exe is used. If I use the path directly to the "real" exe, it works fine. I'll close this since it's not really a FluentTerminal issue, but have included my findings as a curiosity to anyone who finds this thread 😝
When using the pwsh.exe
shim that scoop creates directly (not inside FluentTerminal) the issue does not repro, however the process tree shows two processes:
* [A] explorer.exe
* [B] C:\Users\anurse\scoop\shims\pwsh.exe
* [C] C:\Users\anurse\scoop\apps\pwsh\6.1.3\pwsh.exe
When Ctrl-C is pressed, process [B]
(the shim) terminates. However, the actual PowerShell process (Process [C]
) is still alive and is just orphaned.
However, when in FluentTerminal, the process tree is:
* [A] FluentTerminal.SystemTray.exe
* [B] winpty-agent.exe
* [C] C:\Users\anurse\scoop\shims\pwsh.exe
* [D] C:\Users\anurse\scoop\apps\pwsh\6.1.3\pwsh.exe
When I perform the same action here, again it's process [C]
(the shim) that terminates due to the Ctrl-C. However, it looks like something in that process tree (winpty, or FluentTerminal) terminates all the children (including process [D]
, the actual PowerShell process) when [C]
terminates. This is sensible behavior, so I don't think that there's anything FluentTerminal should do differently here.
Just as an FYI, there is a fix proposed in scoop for this (so that the shim won't cause such bad behaviour): ScoopInstaller/Scoop#3634