fix: support Windows executable resolution, process-tree termination, and process_is_alive Win32 API - #3
Open
Adityakk9031 wants to merge 2 commits into
Open
fix: support Windows executable resolution, process-tree termination, and process_is_alive Win32 API#3Adityakk9031 wants to merge 2 commits into
Adityakk9031 wants to merge 2 commits into
Conversation
### Description This PR fixes a critical crash that occurs on Windows when Yoke attempts to clean up stale temporary deployments. When `os.kill(pid, 0)` is used to check if a process is alive on Windows, checking a non-existent PID raises `OSError: [WinError 87] The parameter is incorrect` instead of `ProcessLookupError` as it does on Unix. Because this exception was previously uncaught, `deploy_runtime` would crash entirely if there were stale deployment directories in the temp folder left over from dead processes. This change catches `OSError` in `process_is_alive`, correctly treating the process as dead on Windows and allowing the garbage collection of the temporary directories to proceed smoothly. ### Testing - [x] Verified that `pytest tests/test_runtime_deployments.py::test_runtime_deployment_reclaims_only_dead_owned_directories` now passes successfully on Windows without raising `WinError 87`. ### Related Issues Fixes #[Insert Issue Number Here]
Author
|
@divitsheth have a look |
Author
|
@rohans0509 have a look |
… and process_is_alive Win32 API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR makes provider process management and lifetime tracking fully compatible with Windows hosts.
Key changes:
resolve_executable): Resolves command names usingshutil.whichon Windows so npm.CMD/.BATshims (e.g.codex.cmd,claude.cmd) are found onPATHwithout security vulnerabilities from working directory shadowing.process_is_alive): Uses native Win32 APIs (kernel32.OpenProcessandGetExitCodeProcess) viactypesto safely query PID status without raisingOSError: [WinError 87].kill_process_tree): Usestaskkill /PID <pid> /T /Fon Windows to cleanly terminate entire process trees (including npm wrapper shims and descendant child processes), and process groups on POSIX.claude auth statusorcodexreadiness checks from hanging indefinitely when stdout is piped on Windows.Testing
tests/test_executable_resolution.pyfor executable resolution, PATHEXT shim finding, process tree termination, and working directory shadow prevention.tests/test_runtime_deployments.pypasses cleanly on Windows.Fixes #2