terminal: Unexpected behavior of closeOnExit
Environment
Windows 10 version 10.0.18362.0 Windows Terminal 0.7.3291.0 PowerShell Core version 6.2.3
Steps to reproduce
Created a manual profile for PowerShell Core (as an automatic profile won’t get added when it’s installed as a dotnet global tool), like this:
{
"guid": "{1ba0ecbe-ee5f-4f20-80fc-c7f3376445ca}",
"name": "PowerShell Core",
"commandline": "%USERPROFILE%\\.dotnet\\tools\\pwsh.exe",
"startingDirectory": "%USERPROFILE%",
"hidden": false,
"fontFace": "Cascadia Mono PL",
"fontSize": 13,
"colorScheme": "Gruvbox Dark"
}
Create a new PowerShell Core window, then run a native command (.exe) that takes a bit of time to run and then immediately hit Ctrl+C
.
In my case, I’ve tested this running both java applications as well as kubectl get pods --all-namespaces
for my kubernetes cluster.
Expected behavior
I’d expect the native application to handle the Ctrl+C
, terminate, and get back to the PowerShell Core prompt.
Actual behavior
The entire Windows Terminal tab is getting killed, as if the shell had been terminated.
What appears to be going on here is related to the closeOnExit
setting. My original profile used the default value for this, and apparently, Windows Terminal is mistaking the child process terminating due to Ctrl+C
as the PowerShell Core shell terminating, so it’s killing the tab window.
Setting closeOnExit: false
seems to work around this, and lets the tab open, but the default behavior is very surprising, and seems like a bug tracking which process terminated.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 12
- Comments: 21 (10 by maintainers)
Scoop already has an issue, and are working towards a solution: https://github.com/lukesampson/scoop/issues/3634
I can confirm this happening. Also happens when, for example, using ping but aborting directly via CTRL-C, then using
exit
. Result is[process exited with code 3221225786]
.Can confirm it’s definitely worse now.
Now it’s broken with both
closeOnExit
enabled or disabled. ¯_(ツ)_/¯Yep.
I’ve filed an issue upstream on PowerShell here: https://github.com/PowerShell/PowerShell/issues/11314. It looks like they’re ceding ownership of the console to whatever processes happen to be running, and because they are the actual root process, Terminal decides they’ve exited.
With our changes to
closeOnExit
in the upcoming 0.8 release, this’ll actually get worse. Hmm. I’m going to reopen this for right now.