fix(tmux): use KillSessionWithProcesses to prevent zombie bash processes
When Claude sessions were terminated using KillSession(), bash subprocesses spawned by Claude's Bash tool could survive because they ignore SIGHUP. This caused zombie processes to accumulate over time. Changed all critical session termination paths to use KillSessionWithProcesses() which explicitly kills all descendant processes before terminating the session. Fixes: gt-ew3tk Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -179,7 +179,9 @@ func (d *Daemon) executeLifecycleAction(request *LifecycleRequest) error {
|
||||
switch request.Action {
|
||||
case ActionShutdown:
|
||||
if running {
|
||||
if err := d.tmux.KillSession(sessionName); err != nil {
|
||||
// Use KillSessionWithProcesses to ensure all descendant processes are killed.
|
||||
// This prevents orphan bash processes from Claude's Bash tool surviving session termination.
|
||||
if err := d.tmux.KillSessionWithProcesses(sessionName); err != nil {
|
||||
return fmt.Errorf("killing session: %w", err)
|
||||
}
|
||||
d.logger.Printf("Killed session %s", sessionName)
|
||||
@@ -188,8 +190,8 @@ func (d *Daemon) executeLifecycleAction(request *LifecycleRequest) error {
|
||||
|
||||
case ActionCycle, ActionRestart:
|
||||
if running {
|
||||
// Kill the session first
|
||||
if err := d.tmux.KillSession(sessionName); err != nil {
|
||||
// Kill the session first - use KillSessionWithProcesses to prevent orphan processes.
|
||||
if err := d.tmux.KillSessionWithProcesses(sessionName); err != nil {
|
||||
return fmt.Errorf("killing session: %w", err)
|
||||
}
|
||||
d.logger.Printf("Killed session %s for restart", sessionName)
|
||||
|
||||
Reference in New Issue
Block a user