fix(gateway): preserve Ctrl+C for Windows foreground runs - #22752
Merged
Conversation
helix4u
marked this pull request as ready for review
May 9, 2026 18:36
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fixes foreground Windows gateway runs so Ctrl+C / Ctrl+Break stop
hermes gateway runagain, while keeping detached Windows gateway launches protected from stray console-control broadcasts.Root cause:
run_gateway()unconditionally ignored SIGINT/SIGBREAK on Windows and installedSetConsoleCtrlHandler(NULL, TRUE), which also disabled user Ctrl+C/Ctrl+Break in PowerShell/CMD foreground runs.The fix scopes that control-event absorption to detached/background gateway launches. Windows service-style launchers now set
HERMES_GATEWAY_DETACHED=1; manual foreground runs keep normal interrupt handling.Related Issue
No GitHub issue yet. Reported from Discord support: Windows PowerShell
hermes gateway runcould not be killed with Ctrl+C or Ctrl+Break.Type of Change
Changes Made
hermes_cli/gateway.py: add Windows foreground-vs-detached detection and only install SIGINT/SIGBREAK/console-control ignore handlers for detached gateway runs.hermes_cli/gateway_windows.py: mark Windows Scheduled Task / Startup / direct detached launches withHERMES_GATEWAY_DETACHED=1.tests/hermes_cli/test_gateway.py: cover both foreground Windows runs preserving Ctrl+C and detached Windows runs absorbing console-control events.How to Test
hermes gateway run.hermes gateway startor the Scheduled Task path and confirm the gateway stays detached/background-managed.python -m pytest tests/hermes_cli/test_gateway.py -q.Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/AFor New Skills
N/A.
Screenshots / Logs
Targeted test:
python -m pytest tests/hermes_cli/test_gateway.py -qResult:
27 passed in 6.11s.Full suite:
scripts/run_tests.shResult:
24 failed, 21359 passed, 59 skipped, 238 warnings in 477.78s.Observed failures were outside the changed Windows gateway signal files/tests, including gateway approval/topic/config, DingTalk card lifecycle, Discord bot filter, auxiliary client, API server defaults, TTS media routing, update flow, Tencent TokenHub context length, interrupt propagation, code execution timeout/interrupt handling, process registry, Tirith marker cleanup, and TTS command timeout tests.
HERMES_HOMEwas empty before and after the full-suite run.