fix(desktop): watchdog shutdown must not hard-kill on Windows - #302
Merged
Conversation
added 2 commits
July 17, 2026 01:34
The desktop parent watchdog used os.kill(os.getpid(), SIGTERM) to stop the backend, with a comment promising uvicorn's shutdown sequence would run. On Windows that call is TerminateProcess -- a hard kill that bypasses every cleanup path, so the promise only held on POSIX. signal.raise_signal(SIGTERM) triggers the in-process Python-level handler uvicorn installed, with identical semantics on both platforms. Closes #282
6 tasks
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.
Closes #282. Phase 2 of #273 — plan: #273 (comment) (PR-2D).
What
_desktop_parent_watchdogstopped the backend withos.kill(os.getpid(), signal.SIGTERM), commented as "so uvicorn runs its shutdown sequence." That's only true on POSIX — on Windows,os.killwith SIGTERM isTerminateProcess, a hard kill that bypasses every cleanup path. Low impact today (the registry persists per-job), but any future shutdown hook would silently never run on Windows desktop.One-line root-cause fix:
signal.raise_signal(signal.SIGTERM)triggers the in-process Python-level handler uvicorn installed viasignal.signal, with identical semantics on both platforms. Comment updated to say why.Testing
New
tests/test_watchdog.py: dead parent → exactly one in-processraise_signal(SIGTERM)and zeroos.killcalls; alive parent → loops without signaling until the parent disappears.Full suite: 182 passed; ruff clean.
🤖 Generated with Claude Code