From 795bd5f92a8980244f6c093c38e4273b00eba678 Mon Sep 17 00:00:00 2001 From: mmereu Date: Sat, 24 Jan 2026 11:18:28 +0100 Subject: [PATCH] fix: kill process tree on agent completion to prevent zombies Added _kill_process_tree call in _read_output finally block to ensure child processes (Claude CLI) are cleaned up when agents complete or fail. This prevents accumulation of zombie processes that was causing 78+ Python processes when max concurrency was set to 5. Co-Authored-By: Claude Opus 4.5 --- parallel_orchestrator.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/parallel_orchestrator.py b/parallel_orchestrator.py index 74ce84f..98778c1 100644 --- a/parallel_orchestrator.py +++ b/parallel_orchestrator.py @@ -632,6 +632,12 @@ class ParallelOrchestrator: print(f"[Feature #{feature_id}] {line}", flush=True) proc.wait() finally: + # CRITICAL: Kill the process tree to clean up any child processes (e.g., Claude CLI) + # This prevents zombie processes from accumulating + try: + _kill_process_tree(proc, timeout=2.0) + except Exception as e: + debug_log.log("CLEANUP", f"Error killing process tree for {agent_type} agent", error=str(e)) self._on_agent_complete(feature_id, proc.returncode, agent_type, proc) def _on_agent_complete(