fix(shell): reap zombie processes when command timeout kills subprocess

This commit is contained in:
Eric Yang
2026-03-22 16:24:37 +00:00
committed by Xubin Ren
parent 97fe9ab7d4
commit e423ceef9c

View File

@@ -109,6 +109,11 @@ class ExecTool(Tool):
try: try:
await asyncio.wait_for(process.wait(), timeout=5.0) await asyncio.wait_for(process.wait(), timeout=5.0)
except asyncio.TimeoutError: except asyncio.TimeoutError:
try:
os.waitpid(process.pid, os.WNOHANG)
except (ProcessLookupError, ChildProcessError):
pass
except ProcessLookupError:
pass pass
return f"Error: Command timed out after {effective_timeout} seconds" return f"Error: Command timed out after {effective_timeout} seconds"