You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implement cross-platform subprocess and children termination
- Add process group support on POSIX systems via start_new_session=True
- Implement _terminate_process_with_children() and _kill_process_and_children()
functions that properly handle child process cleanup
- On POSIX: Kill entire process group at once to avoid orphaning children
when parent dies first
- On Windows: Use taskkill /T for process tree termination
- Add pid property to FallbackProcess for consistent interface
- Add proper type annotations (Process | FallbackProcess)
- Replace existing termination logic with new unified approach
This addresses issues from PRs #850 (npx child processes) and #729
(Windows process trees) in a unified, dependency-free way.
Reported-by:surya-prakash-susarla
Reported-by:jingx8885
Github-Issue:#547
Add regression tests for child process termination
- test_stdio_client_child_process_cleanup: Verifies that child processes
spawned by the parent (like npx spawning node) are properly terminated
- test_stdio_client_nested_process_tree: Tests that deeply nested process
trees (parent -> child -> grandchild) are all terminated
- test_stdio_client_early_parent_exit: Tests the race condition where
parent exits during cleanup but children are still terminated via
process group
These tests verify the fix works correctly across different subprocess
spawning scenarios without requiring external dependencies like psutil.
0 commit comments