Skip to content

fix: infigraph watch releases its lock file on SIGTERM, not just Ctrl-C - #42

Open
pradeepmouli wants to merge 1 commit into
intuit:mainfrom
pradeepmouli:fix/watch-sigterm-lock-release
Open

fix: infigraph watch releases its lock file on SIGTERM, not just Ctrl-C#42
pradeepmouli wants to merge 1 commit into
intuit:mainfrom
pradeepmouli:fix/watch-sigterm-lock-release

Conversation

@pradeepmouli

Copy link
Copy Markdown
Contributor

Summary

ctrlc::set_handler (used in cmd_watch, crates/infigraph-cli/src/info_commands.rs) only catches SIGINT by default on Unix — SIGTERM (and SIGHUP) require the crate's termination feature. Without it, stopping infigraph watch via kill/pkill/any process-manager-style shutdown (not just interactive Ctrl-C) bypasses the existing graceful stop_rx-based shutdown path entirely: the OS kills the process directly, no Rust destructors run, and watch.lock is 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 watch invocation from acquiring the lock (or at minimum left misleading stale state) until the file was manually cleared.

Fix

One-line dependency change — enable the ctrlc crate's termination feature so the same set_handler closure (already correctly wired to the existing graceful-shutdown stop_rx channel) also fires on SIGTERM/SIGHUP, not just SIGINT.

Test plan

  • Manually verified: before this change, kill -TERM on a running infigraph watch process terminates it immediately with no "Watch stopped." message and a stale watch.lock.
  • After this change, kill -TERM prints "Watch stopped." (the existing graceful shutdown path) and clears watch.lock, matching Ctrl-C behavior exactly.
  • cargo fmt --all -- --check — clean
  • cargo clippy -p infigraph-cli --all-targets -- -D warnings — clean

🤖 Generated with Claude Code

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
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.

1 participant