fix: handle os.kill on Windows for process checking#4129
Open
hztBUAA wants to merge 2 commits intobrowser-use:mainfrom
Open
fix: handle os.kill on Windows for process checking#4129hztBUAA wants to merge 2 commits intobrowser-use:mainfrom
hztBUAA wants to merge 2 commits intobrowser-use:mainfrom
Conversation
The _is_process_alive and _kill_process functions in tunnel.py used os.kill(pid, 0) and os.kill(pid, signal.SIGKILL) which fail on Windows. Added sys.platform checks with ctypes fallbacks matching the pattern already used in utils.py and main.py. Fixes browser-use#3912
|
|
Author
|
Thanks for the review and feedback. I am following up on this PR now and will either push the requested changes or reply point-by-point shortly. |
Author
|
Quick follow-up: I am reviewing the feedback and will update this PR shortly. |
Member
|
@hztBUAA, thank you for the PR; it looks good. Please sign the Contributor License Agreement so I can merge it. |
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.
Summary
_is_process_alive()and_kill_process()inbrowser_use/skill_cli/tunnel.pyto work on Windows by addingsys.platform == 'win32'guards withctypes.windll.kernel32.OpenProcess/TerminateProcessfallbacksutils.pyandmain.py(_pid_existsandkill_orphaned_server)os.kill(pid, 0)raisesSystemErroron Windows because signal 0 is not supported;os.kill(pid, signal.SIGKILL)also fails sinceSIGKILLis Unix-onlyFixes #3912
Test plan
_is_process_alive()correctly detects running/dead processes on Windows_kill_process()can terminate cloudflared tunnel processes on WindowsSummary by cubic
Fix Windows process detection and termination in tunnel.py by using Win32 APIs instead of os.kill. Prevents crashes from unsupported signals and keeps Unix behavior unchanged.
Written for commit 891c237. Summary will update on new commits.