Terminal doesn't respond to SIGINT (CTRL+C KeyboardInterrupt) when running as administrator #7536

Closed
opened 2026-01-31 01:06:28 +00:00 by claunia · 15 comments
Owner

Originally created by @403-Fruit on GitHub (Apr 22, 2020).

Environment

Windows build number: Windows NT 10.0.19041.0
Windows Terminal version: Version: 0.10.781.0

Steps to reproduce

  • Start one terminal as administrator, and one normally
  • Using PowerShell or cmd (didn't test other shells), start some continuous process, e.g ping -t localhost
  • Try to interrupt process with ctrl+c on each terminal.
  • Observe that it only works on the unelevated terminal.

Expected behavior

SIGINT causes console process to exit, regardless of elevation

Actual behavior

Process does not respond to SIGINT, and requires manual termination from taskmgr or another shell

Originally created by @403-Fruit on GitHub (Apr 22, 2020). <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 I ACKNOWLEDGE THE FOLLOWING BEFORE PROCEEDING: 1. If I delete this entire template and go my own path, the core team may close my issue without further explanation or engagement. 2. If I list multiple bugs/concerns in this one issue, the core team may close my issue without further explanation or engagement. 3. If I write an issue that has many duplicates, the core team may close my issue without further explanation or engagement (and without necessarily spending time to find the exact duplicate ID number). 4. If I leave the title incomplete when filing the issue, the core team may close my issue without further explanation or engagement. 5. If I file something completely blank in the body, the core team may close my issue without further explanation or engagement. All good? Then proceed! --> <!-- This bug tracker is monitored by Windows Terminal development team and other technical folks. **Important: When reporting BSODs or security issues, DO NOT attach memory dumps, logs, or traces to Github issues**. Instead, send dumps/traces to secure@microsoft.com, referencing this GitHub issue. If this is an application crash, please also provide a Feedback Hub submission link so we can find your diagnostic data on the backend. Use the category "Apps > Windows Terminal (Preview)" and choose "Share My Feedback" after submission to get the link. Please use this form and describe your issue, concisely but precisely, with as much detail as possible. --> # Environment ```none Windows build number: Windows NT 10.0.19041.0 Windows Terminal version: Version: 0.10.781.0 ``` # Steps to reproduce * Start one terminal as administrator, and one normally * Using PowerShell or cmd (didn't test other shells), start some continuous process, e.g ```ping -t localhost``` * Try to interrupt process with ctrl+c on each terminal. * Observe that it only works on the unelevated terminal. # Expected behavior SIGINT causes console process to exit, regardless of elevation # Actual behavior Process does not respond to SIGINT, and requires manual termination from taskmgr or another shell
Author
Owner

@DHowett-MSFT commented on GitHub (Apr 22, 2020):

Can't repro this, as admin.

image

@DHowett-MSFT commented on GitHub (Apr 22, 2020): Can't repro this, as admin. ![image](https://user-images.githubusercontent.com/14316954/79946405-c494da00-8424-11ea-9831-03d743008a66.png)
Author
Owner

@403-Fruit commented on GitHub (Apr 22, 2020):

I think it's the way I'm launching it, as it's a bit improper. I have a shortcut on my taskbar with the target

C:\Windows\System32\cmd.exe /c start /b wt

that is set to run as administrator, just so that it defaults to admin. I just tried and it works as expected if I Right click -> Run as Administrator.

I can't remember why I used the above target, but setting it to wt.exe appears to produce the desired behavior, and CTRL+C works fine.

@403-Fruit commented on GitHub (Apr 22, 2020): I think it's the way I'm launching it, as it's a bit improper. I have a shortcut on my taskbar with the target ```C:\Windows\System32\cmd.exe /c start /b wt``` that is set to run as administrator, just so that it defaults to admin. I just tried and it works as expected if I `Right click -> Run as Administrator`. I can't remember why I used the above target, but setting it to `wt.exe` appears to produce the desired behavior, and CTRL+C works fine.
Author
Owner

@DHowett-MSFT commented on GitHub (Apr 22, 2020):

Ah, thanks for following up. That’s really quite strange. I’m not sure there’s anything we can do about that; perhaps there is something strange about app activation in this context... ☹️

For now, I’ll resolve this one as External. Please let me know if you have any other ideas or any other leads.

@DHowett-MSFT commented on GitHub (Apr 22, 2020): Ah, thanks for following up. That’s really quite strange. I’m not sure there’s anything we can do about that; perhaps there is something strange about app activation in this context... ☹️ For now, I’ll resolve this one as External. Please let me know if you have any other ideas or any other leads.
Author
Owner

@eryksun commented on GitHub (Apr 22, 2020):

I think it's the way I'm launching it, as it's a bit improper. I have a shortcut on my taskbar with the target

C:\Windows\System32\cmd.exe /c start /b wt

Why doesn't the shortcut simply run wt.exe?

The /b option of CMD's start command calls CreateProcessW with the creation flag CREATE_NEW_PROCESS_GROUP and without the flag CREATE_NEW_CONSOLE, so it sort of acts like running a background process in the current console session, especially if combined with redirecting the process standard input to NUL.

A process that's created in a new console process group initially has Ctrl+C disabled (i.e. the ConsoleFlags in the PEB process parameters has the first bit set). I guess it's because only 'foreground' processes should see Ctrl+C. This setting gets inherited by child processes.

Interestingly, this flag remains set in the process parameters and inheritable even if we run a non-console application such as Windows Terminal. I suggest that Windows Terminal should clear this flag to enable Ctrl+C on startup via SetConsoleCtrlHandler(NULL, False).

@eryksun commented on GitHub (Apr 22, 2020): > I think it's the way I'm launching it, as it's a bit improper. I have a shortcut on my taskbar with the target > > `C:\Windows\System32\cmd.exe /c start /b wt` Why doesn't the shortcut simply run wt.exe? The `/b` option of CMD's `start` command calls `CreateProcessW` with the creation flag `CREATE_NEW_PROCESS_GROUP` and without the flag `CREATE_NEW_CONSOLE`, so it sort of acts like running a background process in the current console session, especially if combined with redirecting the process standard input to NUL. A process that's created in a new console process group initially has Ctrl+C disabled (i.e. the `ConsoleFlags` in the PEB process parameters has the first bit set). I guess it's because only 'foreground' processes should see Ctrl+C. This setting gets inherited by child processes. Interestingly, this flag remains set in the process parameters and inheritable even if we run a non-console application such as Windows Terminal. I suggest that Windows Terminal should clear this flag to enable Ctrl+C on startup via `SetConsoleCtrlHandler(NULL, False)`.
Author
Owner

@DHowett-MSFT commented on GitHub (Apr 22, 2020):

Good catch, @eryksun. Thanks!

@DHowett-MSFT commented on GitHub (Apr 22, 2020): Good catch, @eryksun. Thanks!
Author
Owner

@403-Fruit commented on GitHub (Apr 23, 2020):

Why doesn't the shortcut simply run wt.exe?

@eryksun That's a mistake on my part. I don't quite remember why I ended up with that, and it seems completely unnecessary in hindsight. Thanks for the insight.

@403-Fruit commented on GitHub (Apr 23, 2020): > Why doesn't the shortcut simply run wt.exe? @eryksun That's a mistake on my part. I don't quite remember why I ended up with that, and it seems completely unnecessary in hindsight. Thanks for the insight.
Author
Owner

@403-Fruit commented on GitHub (Apr 23, 2020):

By the way, you guys are doing an awesome job with the Terminal. It's a home run IMO, and I'm genuinely excited to see what comes next 👍

@403-Fruit commented on GitHub (Apr 23, 2020): By the way, you guys are doing an awesome job with the Terminal. It's a home run IMO, and I'm genuinely excited to see what comes next 👍
Author
Owner

@ghost commented on GitHub (Apr 29, 2020):

:tada:This issue was addressed in #5472, which has now been successfully released as Windows Terminal Preview v0.11.1191.0.🎉

Handy links:

@ghost commented on GitHub (Apr 29, 2020): :tada:This issue was addressed in #5472, which has now been successfully released as `Windows Terminal Preview v0.11.1191.0`.:tada: Handy links: * [Release Notes](https://github.com/microsoft/terminal/releases/tag/v0.11.1191.0) * [Store Download](https://www.microsoft.com/store/apps/9n0dx20hk701?cid=storebadge&ocid=badge)
Author
Owner

@ribbles commented on GitHub (Mar 13, 2022):

Still seeing this intermittently in v1.6.10571.0.

@ribbles commented on GitHub (Mar 13, 2022): Still seeing this intermittently in `v1.6.10571.0`.
Author
Owner

@zadjii-msft commented on GitHub (Mar 14, 2022):

@ribbles I'd probably try filing a new issue then, including what shell you're using and your settings file. This one is getting close to 2 years old, so if you're seeing this it's likely a totally different issue. I'd also try updating the Terminal, 1.6 is very old now 😝

@zadjii-msft commented on GitHub (Mar 14, 2022): @ribbles I'd probably try filing a new issue then, including what shell you're using and your settings file. This one is getting close to 2 years old, so if you're seeing this it's likely a totally different issue. I'd also try updating the Terminal, 1.6 is _very_ old now 😝
Author
Owner

@vladsol commented on GitHub (Mar 29, 2022):

Windows terminal 1.11.3471.0

I can reproduce this problem.

Windows terminal stopped responding on Ctrl + C after executing and just trying to log-in by ssh on any host.

@vladsol commented on GitHub (Mar 29, 2022): Windows terminal 1.11.3471.0 I can reproduce this problem. Windows terminal stopped responding on Ctrl + C after executing and just trying to log-in by ssh on any host.
Author
Owner

@jacobrastad commented on GitHub (Jul 14, 2022):

I can confirm @vladsol observation as well.

  1. Login with SSH on any remote host. Then exit that
  2. Run ping 8.8.8.8 -t
  3. Try to exit with ctrl+c

System info:
Windows 11 21H2, 22000.795
Terminal version: 1.13.11432.0

@jacobrastad commented on GitHub (Jul 14, 2022): I can confirm @vladsol observation as well. 1. Login with SSH on any remote host. Then exit that 2. Run `ping 8.8.8.8 -t` 3. Try to exit with `ctrl+c` System info: Windows 11 21H2, 22000.795 Terminal version: 1.13.11432.0
Author
Owner

@jacobrastad commented on GitHub (Jul 14, 2022):

Created a new issue for this at https://github.com/microsoft/terminal/issues/13503

@jacobrastad commented on GitHub (Jul 14, 2022): Created a new issue for this at https://github.com/microsoft/terminal/issues/13503
Author
Owner

@mikizdr commented on GitHub (Jul 28, 2024):

ctrl + c doesn't work

@mikizdr commented on GitHub (Jul 28, 2024): ctrl + c doesn't work
Author
Owner

@DHowett commented on GitHub (Jul 29, 2024):

If you are experiencing this issue, file a new bug and fill out the template. This one is four years old and has been closed for the majority of that time.

@DHowett commented on GitHub (Jul 29, 2024): If you are experiencing this issue, file a new bug and fill out the template. This one is four years old and has been closed for the majority of that time.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#7536