kill: refuse to kill/stop the session you're currently inside (mirrors attach's self-check) - #51
Open
FpTargeT wants to merge 1 commit into
Open
kill: refuse to kill/stop the session you're currently inside (mirrors attach's self-check)#51FpTargeT wants to merge 1 commit into
FpTargeT wants to merge 1 commit into
Conversation
attach_main already refuses to attach to a session in the caller's own ancestry chain (SESSION_ENVVAR), with a clear message. kill_main had no equivalent check, so running `atch kill <own-session>` (or `kill -f`) from inside that session just raced the signal against the caller's own exit, with no explanation -- confusing especially for plain `kill`, which then waits out the full 5-second grace period before reporting. Extracted the existing ancestry-chain scan from attach_main into a shared session_in_ancestry() helper (no behavior change for attach), and added the same check to the top of kill_main with a kill-specific message. Added 3 new integration test scenarios (6 assertions) covering: self-kill without -f, self-kill with -f, and a control case confirming a non-ancestor session's kill is unaffected. Full suite: 235/235 passing (229 pre-existing + 6 new), 0 regressions.
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.
Problem
`attach_main` already refuses to attach to a session that's in the caller's own ancestry chain (`SESSION_ENVVAR`), printing a clear message: `cannot attach to session '%s' from within itself`.
`kill_main` has no equivalent check. Running `atch kill ` (or `atch kill -f`) from inside the session you're trying to kill just races the SIGTERM/SIGKILL against your own shell's exit, with no explanation — confusing, especially for plain `kill` (no `-f`), which then waits out the full 5-second grace period before reporting.
Fix
Testing
Full suite run locally: 235/235 passing (229 pre-existing + 6 new), 0 regressions. Built clean with `make`, no new warnings.