Unexpected behavior of closeOnExit #5432

Open
opened 2026-01-31 00:13:11 +00:00 by claunia · 0 comments
Owner

Originally created by @tomasr on GitHub (Dec 6, 2019).

Originally assigned to: @DHowett on GitHub.

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.

Originally created by @tomasr on GitHub (Dec 6, 2019). Originally assigned to: @DHowett on GitHub. # 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: ```json { "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.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#5432