Skip to content

Commit 0629a3f

Browse files
committed
On Linux, terminating a process that has already exited raises ProcessLookupError. This can happen if the command failed to launch properly (as in this test case).
1 parent d5e46c6 commit 0629a3f

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/mcp/client/stdio/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,13 @@ async def stdin_writer():
182182
if sys.platform == "win32":
183183
await terminate_windows_process(process)
184184
else:
185-
process.terminate()
185+
# On Linux, terminating a process that has already exited raises ProcessLookupError.
186+
# This can happen if the command failed to launch properly (as in this test case).
187+
try:
188+
process.terminate()
189+
except ProcessLookupError:
190+
# Process already exited — safe to ignore
191+
pass
186192
await read_stream.aclose()
187193
await write_stream.aclose()
188194

0 commit comments

Comments
 (0)