From f89ac47ff9db86acd05810c20b8d11d4ed67018c Mon Sep 17 00:00:00 2001 From: aleiby Date: Fri, 16 Jan 2026 15:25:52 -0800 Subject: [PATCH] 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 --- internal/tmux/tmux.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/internal/tmux/tmux.go b/internal/tmux/tmux.go index 749106ea..12c1f8c4 100644 --- a/internal/tmux/tmux.go +++ b/internal/tmux/tmux.go @@ -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