From e423ceef9c7092d63ad797d5f6cfa8784bc98377 Mon Sep 17 00:00:00 2001 From: Eric Yang Date: Sun, 22 Mar 2026 16:24:37 +0000 Subject: [PATCH] fix(shell): reap zombie processes when command timeout kills subprocess --- nanobot/agent/tools/shell.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/nanobot/agent/tools/shell.py b/nanobot/agent/tools/shell.py index 4b10c83..9996684 100644 --- a/nanobot/agent/tools/shell.py +++ b/nanobot/agent/tools/shell.py @@ -109,6 +109,11 @@ class ExecTool(Tool): try: await asyncio.wait_for(process.wait(), timeout=5.0) except asyncio.TimeoutError: + try: + os.waitpid(process.pid, os.WNOHANG) + except (ProcessLookupError, ChildProcessError): + pass + except ProcessLookupError: pass return f"Error: Command timed out after {effective_timeout} seconds"