Add _is_claude_process(pid) that reads /proc/{pid}/comm to verify a process is claude or node before sending SIGKILL
Update _kill_agent() to call _is_claude_process() and skip the kill (with a warning) if the PID was recycled
Add TestIsClaudeProcess test class and update TestKillAgent tests to patch the new guard
Fixes the TOCTOU/PID-recycling risk described in #160: if the original claude process exits between cron ticks and the kernel reuses its PID, the loop will now refuse to kill the unrelated process instead of blindly sending SIGKILL.
Test plan
python3 scripts/test_agent_loop.py -v passes all new and existing tests (pre-existing failure in test_ci_fix_preserves_pending_issue_in_state is unrelated to this PR)
task check passes in CI
## Summary
- Add `_is_claude_process(pid)` that reads `/proc/{pid}/comm` to verify a process is `claude` or `node` before sending SIGKILL
- Update `_kill_agent()` to call `_is_claude_process()` and skip the kill (with a warning) if the PID was recycled
- Add `TestIsClaudeProcess` test class and update `TestKillAgent` tests to patch the new guard
Fixes the TOCTOU/PID-recycling risk described in #160: if the original claude process exits between cron ticks and the kernel reuses its PID, the loop will now refuse to kill the unrelated process instead of blindly sending SIGKILL.
## Test plan
- [ ] `python3 scripts/test_agent_loop.py -v` passes all new and existing tests (pre-existing failure in `test_ci_fix_preserves_pending_issue_in_state` is unrelated to this PR)
- [ ] `task check` passes in CI
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Summary
_is_claude_process(pid)that reads/proc/{pid}/commto verify a process isclaudeornodebefore sending SIGKILL_kill_agent()to call_is_claude_process()and skip the kill (with a warning) if the PID was recycledTestIsClaudeProcesstest class and updateTestKillAgenttests to patch the new guardFixes the TOCTOU/PID-recycling risk described in #160: if the original claude process exits between cron ticks and the kernel reuses its PID, the loop will now refuse to kill the unrelated process instead of blindly sending SIGKILL.
Test plan
python3 scripts/test_agent_loop.py -vpasses all new and existing tests (pre-existing failure intest_ci_fix_preserves_pending_issue_in_stateis unrelated to this PR)task checkpasses in CI