Skip to content

feat: implement Windows console signal handling for daemon mode#3041

Merged
oferchen merged 2 commits intomasterfrom
feat/windows-daemon-phase1
Mar 29, 2026
Merged

feat: implement Windows console signal handling for daemon mode#3041
oferchen merged 2 commits intomasterfrom
feat/windows-daemon-phase1

Conversation

@oferchen
Copy link
Copy Markdown
Owner

Summary

  • Replace the no-op Windows signal handler stub with a real SetConsoleCtrlHandler implementation
  • CTRL_C and CTRL_CLOSE set the shutdown flag (same as SIGTERM/SIGINT on Unix)
  • CTRL_BREAK sets the graceful_exit flag (same as SIGUSR1 on Unix)
  • Gate daemonize.rs functions with #[cfg(unix)] since fork/setsid are Unix-only
  • Add windows crate dependency with Win32_System_Console and Win32_Foundation features
  • Clean up signal handler comments to use concise rustdoc
  • Include full Windows daemon design document (docs/plans/2026-03-29-windows-daemon-design.md)

This is Phase 1 of 3 for full Windows daemon support. Phase 2 adds privilege dropping and name resolution. Phase 3 adds Windows Service (SCM) integration.

Test plan

  • Unix signal handling unchanged (macOS + Linux CI)
  • Windows CI builds and tests pass with new SetConsoleCtrlHandler
  • windows_register_signal_handlers_succeeds test passes on Windows
  • Daemonize tests properly gated with #[cfg(all(test, unix))]

Replace the no-op Windows signal handler stub with a real
SetConsoleCtrlHandler implementation:
- CTRL_C_EVENT and CTRL_CLOSE_EVENT set the shutdown flag
- CTRL_BREAK_EVENT sets the graceful_exit flag

Also gates daemonize.rs functions with #[cfg(unix)] since fork/setsid
are Unix-only. Adds the windows crate dependency with Win32_System_Console
and Win32_Foundation features.

Includes the full Windows daemon design document covering all 3 phases:
console signals (this PR), privilege/name resolution, and SCM service.
Remove redundant comments that restate the code. Keep upstream
references (main.c SIGACT) and non-obvious context (SIGPIPE
prevents daemon termination). Tighten struct field docs.
@github-actions github-actions Bot added the enhancement New feature or request label Mar 29, 2026
@oferchen oferchen merged commit 44143cf into master Mar 29, 2026
38 of 42 checks passed
@oferchen oferchen deleted the feat/windows-daemon-phase1 branch March 29, 2026 00:27
@oferchen oferchen mentioned this pull request Apr 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant