mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-04-02 09:22:36 +00:00
fix(shell): reap zombie processes when command timeout kills subprocess
This commit is contained in:
parent
97fe9ab7d4
commit
e423ceef9c
@ -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"
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user