The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(mcp): stdio child PID snapshot reads every thread's /proc children
Teknium696d854b97a8
diff --git a/tools/mcp_tool.py b/tools/mcp_tool.pyindex 288db83deb8..bbd7f9a484b 100644--- a/tools/mcp_tool.py+++ b/tools/mcp_tool.py@@ -5410,11 +5410,26 @@ def _snapshot_child_pids() -> set:"""my_pid = os.getpid()- # Linux: read from /proc+ # Linux: read from /proc. ``/proc/<pid>/task/<tid>/children`` is+ # per-THREAD — a child forked from thread T is listed only under T's+ # task dir. stdio_client() spawns from the background MCP loop thread,+ # so reading only the main thread's file (``task/<pid>/children``)+ # returned an empty set on every Linux install and left+ # ``_stdio_child_pids`` / ``_stdio_pids`` empty: the #81995 dead-child+ # fast-fail, the #96452 respawn signal, and the killpg shutdown sweep+ # never saw the subprocess. Union the children of every task instead.try:- children_path = f"/proc/{my_pid}/task/{my_pid}/children"- with open(children_path, encoding="utf-8") as f:- return {int(p) for p in f.read().split() if p.strip()}+ task_dir = f"/proc/{my_pid}/task"+ tids = os.listdir(task_dir)+ found: set = set()+ for tid in tids:+ try:+ with open(f"{task_dir}/{tid}/children", encoding="utf-8") as f:+ found.update(int(p) for p in f.read().split() if p.strip())+ except (FileNotFoundError, OSError, ValueError):+ # Thread exited between listdir and open — skip it.+ continue+ return foundexcept (FileNotFoundError, OSError, ValueError):pass