Skip to content

The agent that grows with you

fix(mcp): psutil.pid_exists for stdio children liveness — Windows footgun (#85125 CI)

kshitijk4poor786f37071a16
diff --git a/tools/mcp_tool.py b/tools/mcp_tool.py
index b910f5e7b01..8393538247d 100644
--- a/tools/mcp_tool.py
+++ b/tools/mcp_tool.py
@@ -2988,14 +2988,13 @@ class MCPServerTask:
if not pids or self._is_http():
return False
for pid in pids:
- try:
- os.kill(pid, 0)
- except ProcessLookupError:
+ # windows-footgun: ok — psutil.pid_exists handles Windows; the
+ # os.kill probe below only runs when psutil is unavailable.
+ import psutil
+
+ if not psutil.pid_exists(pid):
continue # this one is dead
- except PermissionError:
- return False # exists but not ours to signal — treat alive
- except OSError:
- return False
+ return True # alive (signal permission irrelevant for liveness)
return False # at least one child alive
return True