Fix Windows: registry write crash, process liveness probes, and drive-relative /tmp paths - #7
Open
neelsvan wants to merge 3 commits into
Open
Fix Windows: registry write crash, process liveness probes, and drive-relative /tmp paths#7neelsvan wants to merge 3 commits into
neelsvan wants to merge 3 commits into
Conversation
os.rename fails with FileExistsError (WinError 183) when the destination exists, which is every save after the first one -- launch crashed on a clean Windows machine after creating the initial registry file. os.replace overwrites atomically on all platforms and is the documented replacement.
os.kill(pid, 0) is a POSIX idiom; on Windows signal 0 maps to CTRL_C_EVENT and raises OSError (WinError 87, 'The parameter is incorrect') for ordinary processes, so every registry liveness check crashed: status, stop, attach and cleanup were unusable. Probe with OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION) instead (ERROR_ACCESS_DENIED still proves existence), and add a GetProcessTimes-based start-time token so the PID-reuse identity check also works on Windows instead of silently returning None. POSIX code paths are unchanged.
"/tmp/chrome-agent" is drive-relative on Windows: it resolves against the current drive, so instances registered while working on one drive are invisible from another and every command reports "No instances registered". Resolve the registry and session root against tempfile.gettempdir() on Windows; POSIX behavior is unchanged.
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
Three fixes that make the CLI usable on Windows. All changes are behind
sys.platform == "win32"except theos.rename->os.replaceswap, which is equivalent-or-better on POSIX. No POSIX behavior changes.1.
os.replacefor registry writes (registry.py)os.renameraisesFileExistsError(WinError 183) when the destination exists -- which is every save after the first.launchcrashed on a clean Windows machine right after creating the initial registry file.2. Windows-safe process liveness probes (
utils.py)os.kill(pid, 0)is a POSIX idiom. On Windows, signal 0 maps toCTRL_C_EVENTand the call raisesOSError(WinError 87, "The parameter is incorrect") for ordinary processes, so every registry liveness check crashed --status,stop,attach, andcleanupwere all unusable. The fix probes withOpenProcess(PROCESS_QUERY_LIMITED_INFORMATION)(ERROR_ACCESS_DENIEDstill proves existence) and adds aGetProcessTimes-based start-time token so the PID-reuse identity check works on Windows too, instead of silently returningNonevia theps -o lstart=fallback.3. Absolute temp paths on Windows (
registry.py,launcher.py)"/tmp/chrome-agent"is drive-relative on Windows -- it resolves against the current drive. Instances registered while working on one drive are invisible from another, and every command reports "No instances registered". The registry and session root now resolve viatempfile.gettempdir()on Windows.Testing
+Network.requestWillBeSent/ stop, from two different drives):main: 29 failed, 49 errors, 86 passed/proc-based sweep identity) and fingerprint/viewport assertions that do not hold in this environmentmainand this branch (44 passed / 6 failed / 9 errors; every failure isBrowserNotFoundErrorfrom the missing browser), confirming no POSIX regressions in the touched modules (test_registryandtest_pid_identitypass fully).Not addressed (out of scope):
os.kill(pid, 15)inregistry.pymaps toTerminateProcesson Windows rather than a graceful SIGTERM -- functional, but stop is a hard kill there.