Skip to content

fix(process-daemon): let Ctrl+C reach programs in terminals on Windows - #65663

Draft
Hona wants to merge 1 commit into
devfrom
daemon-ctrl-c
Draft

Hona wants to merge 1 commit into
devfrom
daemon-ctrl-c

Conversation

@Hona

@Hona Hona commented Nov 23, 2026

Copy link
Copy Markdown
Member

Issue for this PR

Closes #65662

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

On Windows the daemon now calls SetConsoleCtrlHandler(None, FALSE) once at start, in server::run before any terminal starts (new platform::accept_ctrl_c in daemon/windows.rs). This clears the "ignore Ctrl+C" attribute it got from being started detached in a new process group. Terminals inherit the attribute, so until now Ctrl+C never reached a program in one. The server's in-process terminal does the same in core/src/pty/pty.bun.ts.

The daemon has no console of its own, so no Ctrl+C event reaches the daemon itself, and handlers stay registered. macOS and Linux are untouched: the call is cfg(windows), and Win32_System_Console is added to the Windows-only windows-sys features.

How did you verify your code works?

  • New Windows test ctrl_c_stops_a_program_in_a_terminal_of_a_detached_daemon in tests/windows-daemon.rs. It starts the daemon as Node's detached does (DETACHED_PROCESS | CREATE_NEW_PROCESS_GROUP), runs ping -n 30 127.0.0.1 in a terminal, writes \x03, and expects ping to exit within 10 s. Ignoring Ctrl+C, ping runs its 30 echoes.
  • rustfmt --check on the changed files. I have not built the daemon locally; the Windows job of check-process-daemon.yml compiles and runs it.
  • The same root cause and the one-call fix were verified with a stand-in daemon from the native Rune desktop build: the program stopped with the call and kept running without it.

Screenshots / recordings

No picture: the change is what a terminal's program does on Ctrl+C, which the test above checks.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows: Ctrl+C does not stop a program in a desktop terminal tab

1 participant