fix(daemon): register SIGTERM handler to ensure PID file cleanup#1438
Merged
fix(daemon): register SIGTERM handler to ensure PID file cleanup#1438
Conversation
…hutdown Only ctrl_c() was registered as a signal handler, causing remove_pid_file() to be skipped when the daemon received SIGTERM (standard `kill <pid>`). Replace the single ctrl_c handler with a tokio::select! block covering both SIGINT and SIGTERM. Both signals now trigger shutdown_tx.send(true), allowing the cleanup path (agent.shutdown + remove_pid_file) to always execute. Closes #1414
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.
Summary
SIGTERMhandler alongside the existingCtrl-Chandler using atokio::select!block in the daemon signal taskSIGINTandSIGTERMnow triggershutdown_tx.send(true), ensuringagent.shutdown()andremove_pid_file()are always reached on clean shutdownshutdown_tx_ctrlctoshutdown_tx_signalto reflect the expanded scopeCloses #1414
Test plan
cargo +nightly fmt --check— passcargo clippy --workspace --features full -- -D warnings— pass (0 warnings)cargo nextest run --config-file .github/nextest.toml --workspace --features full --lib --bins— 4869 passed, 11 skippedcrates/zeph-core/src/daemon.rstests coverwrite_pid_file/remove_pid_fileroundtrip andDaemonSupervisorshutdown watch channel