-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Subprocess kill win32 #729
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Subprocess kill win32 #729
Conversation
- Refactor process termination logic to handle both parent and child processes - Increase timeout for graceful termination from 1s to 2s - Consolidate process termination functions to avoid zombie processes - Add proper type hints for process list handling This change ensures that all child processes are properly terminated when killing a parent process on Windows, preventing zombie processes from being left behind.
@dsp-ant require code review |
@dsp-ant require code review, thinks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @jingx8885, thank you for working on this and submitting a PR for process tree termination!
We're currently reviewing PR #555 which takes a simpler, cross-platform approach to the hanging process issue by standardizing the termination logic across all platforms. However, it doesn't modify any Windows behavior, so your change may still be needed.
Before we add the complexity of process tree handling and the psutil
dependency (which also requires setup of Microsoft C++ 14.0 setup apparently in my local testing, so adding more setup complexity), could you help us understand:
- The Windows platform tests are still failing in this PR - could you investigate those failures first? I checked out this PR on my local machine and the tests do still fail.
- Do you have specific test cases or reproduction scenarios where child processes remain hanging after the parent is terminated? If we could create a test or sample script to illustrate the issue you're seeing clearly, that would help us massively in figuring out the right fix.
Given the additional complexity of adding psutil
, we'd prefer to only add complexity if we have concrete cases with failing tests that demonstrate it's needed.
Also I realize this PR has been in queue for a while - if you'd be able to rebase on main to address 1 & 2 above that would be greatly appreciated!
|
- 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
Motivation and Context
How Has This Been Tested?
Breaking Changes
Types of changes
Checklist
Additional context