fix: infigraph watch releases its lock file on SIGTERM, not just Ctrl-C - #42
Open
pradeepmouli wants to merge 1 commit into
Open
fix: infigraph watch releases its lock file on SIGTERM, not just Ctrl-C#42pradeepmouli wants to merge 1 commit into
pradeepmouli wants to merge 1 commit into
Conversation
ctrlc::set_handler only catches SIGINT by default on Unix -- SIGTERM (and SIGHUP) require the crate's "termination" feature. Without it, `kill`/`pkill`/process-manager-style shutdown of `infigraph watch` bypassed the graceful stop_rx path entirely: the OS killed the process directly, no Rust destructors ran, and watch.lock was left with stale acquisition content instead of being cleared. Found via a real incident: a long-running dev-build watcher on an unrelated project grew its graph database to 54GB over several hours (root cause of the growth itself is a separate, still-open investigation) and, when killed to stop it, left its lock file dirty. Verified: after this change, `kill -TERM` on a running `infigraph watch` process now prints "Watch stopped." (the existing graceful shutdown path) and clears watch.lock, matching Ctrl-C behavior exactly. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SjmvwHuwV5r7ZeZpJLp5oR
pradeepmouli
requested review from
johnintuit,
murari316 and
sandeep-mewara
as code owners
July 29, 2026 20:38
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
ctrlc::set_handler(used incmd_watch,crates/infigraph-cli/src/info_commands.rs) only catches SIGINT by default on Unix — SIGTERM (and SIGHUP) require the crate'sterminationfeature. Without it, stoppinginfigraph watchviakill/pkill/any process-manager-style shutdown (not just interactive Ctrl-C) bypasses the existing gracefulstop_rx-based shutdown path entirely: the OS kills the process directly, no Rust destructors run, andwatch.lockis left holding stale acquisition content instead of being released.Found via a real incident: a long-running watcher on a project needed to be killed and left its lock file dirty, which would have blocked a subsequent
infigraph watchinvocation from acquiring the lock (or at minimum left misleading stale state) until the file was manually cleared.Fix
One-line dependency change — enable the
ctrlccrate'sterminationfeature so the sameset_handlerclosure (already correctly wired to the existing graceful-shutdownstop_rxchannel) also fires on SIGTERM/SIGHUP, not just SIGINT.Test plan
kill -TERMon a runninginfigraph watchprocess terminates it immediately with no "Watch stopped." message and a stalewatch.lock.kill -TERMprints"Watch stopped."(the existing graceful shutdown path) and clearswatch.lock, matching Ctrl-C behavior exactly.cargo fmt --all -- --check— cleancargo clippy -p infigraph-cli --all-targets -- -D warnings— clean🤖 Generated with Claude Code