Skip to content

fix(daemon): stop cleanly on Windows - #844

Open
y4ho0 wants to merge 1 commit into
tirth8205:mainfrom
y4ho0:agent/fix-windows-daemon-stop
Open

fix(daemon): stop cleanly on Windows#844
y4ho0 wants to merge 1 commit into
tirth8205:mainfrom
y4ho0:agent/fix-windows-daemon-stop

Conversation

@y4ho0

@y4ho0 y4ho0 commented Aug 12, 2026

Copy link
Copy Markdown

Linked issue

Closes #843

What & why

crg-daemon stop polled process state with os.kill(pid, 0) and escalated with signal.SIGKILL. Both assumptions are POSIX-specific: on Windows the liveness probe does not reliably report an exited process, and SIGKILL is unavailable.

The resulting AttributeError also skipped PID cleanup and prevented crg-daemon restart from starting the daemon again.

This change:

  • reuses the existing cross-platform pid_alive() helper while waiting for shutdown
  • uses SIGKILL when available and falls back to SIGTERM on platforms without it
  • clears the daemon PID in a finally block so a failed forced stop cannot leave stale state
  • adds mocked Windows regressions for forced stop, restart after exit, and PID cleanup after an escalation failure

How it was tested

uv run --python 3.13 pytest tests/ --tb=short -q
# 2401 passed, 5 skipped, 2 xpassed

uv run pytest tests/test_daemon.py --tb=short -q
# 69 passed

uv run ruff check code_review_graph/ tests/test_daemon.py
# All checks passed

uv run mypy code_review_graph/ --ignore-missing-imports --no-strict-optional
# Success: no issues found in 70 source files

bandit -r code_review_graph/ -c pyproject.toml
# No issues identified

AI assistance

OpenAI Codex was used for repository inspection, implementation and test drafting, local verification, and review of the resulting diff.

Checklist

  • Tests added for the corrected behavior
  • All tests pass
  • Linting passes
  • Type checking passes
  • Lines are at most 100 characters
  • Documentation is not required because the CLI interface and expected behavior are unchanged

@y4ho0
y4ho0 marked this pull request as ready for review August 12, 2026 18:40
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.

[Bug][Windows] crg-daemon stop always ends in AttributeError (signal.SIGKILL missing): stale PID file, and restart never restarts

1 participant