fix(tmux): kill pane process explicitly to prevent setsid orphans (#567)
KillSessionWithProcesses was only killing descendant processes, assuming the session kill would terminate the pane process itself. However, if the pane process (claude) calls setsid(), it detaches from the controlling terminal and survives the session kill. This fix explicitly kills the pane PID after killing descendants, before killing the tmux session. This catches processes that have escaped the process tree via setsid(). Fixes #513 Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -182,6 +182,11 @@ func (t *Tmux) KillSessionWithProcesses(name string) error {
|
||||
for _, dpid := range descendants {
|
||||
_ = exec.Command("kill", "-KILL", dpid).Run()
|
||||
}
|
||||
|
||||
// Kill the pane process itself (may have called setsid() and detached)
|
||||
_ = exec.Command("kill", "-TERM", pid).Run()
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
_ = exec.Command("kill", "-KILL", pid).Run()
|
||||
}
|
||||
|
||||
// Kill the tmux session
|
||||
|
||||
Reference in New Issue
Block a user