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:
aleiby
2026-01-16 15:25:52 -08:00
committed by GitHub
parent e344e77921
commit f89ac47ff9

View File

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