MCPcopy
hub / github.com/modelcontextprotocol/python-sdk / _terminate_process_tree

Function _terminate_process_tree

src/mcp/client/stdio.py:290–301  ·  view source on GitHub ↗

Kills the process and all its descendants. POSIX: SIGTERM to the process group, SIGKILL after FORCE_KILL_TIMEOUT. Windows: immediate Job Object termination (already a hard kill).

(process: ServerProcess)

Source from the content-addressed store, hash-verified

288
289
290async def _terminate_process_tree(process: ServerProcess) -> None:
291 """Kills the process and all its descendants.
292
293 POSIX: SIGTERM to the process group, SIGKILL after FORCE_KILL_TIMEOUT.
294 Windows: immediate Job Object termination (already a hard kill).
295 """
296 if sys.platform == "win32": # pragma: no cover
297 await terminate_windows_process_tree(process)
298 else: # pragma: lax no cover
299 # The Windows-only FallbackProcess never reaches the POSIX path.
300 assert isinstance(process, Process)
301 await terminate_posix_process_tree(process, FORCE_KILL_TIMEOUT)
302
303
304def _close_subprocess_transport(process: ServerProcess) -> None:

Calls 2