fix(gateway): add Windows support for gateway process lifecycle#193
Open
Escapingbug wants to merge 1 commit intoHKUDS:mainfrom
Open
fix(gateway): add Windows support for gateway process lifecycle#193Escapingbug wants to merge 1 commit intoHKUDS:mainfrom
Escapingbug wants to merge 1 commit intoHKUDS:mainfrom
Conversation
The ohmo gateway process management (start, find, stop) only worked on Unix-like systems. On Windows, all three operations fail: - start_gateway_process: uses start_new_session=True (no equivalent on Windows; also lacks stdin=DEVNULL which causes the subprocess to inherit the parent's console input) - _pid_is_running: uses os.kill(pid, 0) which raises PermissionError for processes the caller doesn't own on Windows - _iter_workspace_gateway_pids: shells out to `ps`, which doesn't exist on Windows - stop_gateway_process: uses os.kill(pid, SIGTERM), which is not supported on Windows Replace each with a Windows-compatible path guarded by sys.platform: - Start: CREATE_NEW_PROCESS_GROUP | DETACHED_PROCESS, stdin=DEVNULL - PID check: OpenProcess/GetExitCodeProcess via ctypes (STILL_ACTIVE) - PID listing: wmic process where commandline like ... get processid - Stop: taskkill /F /T /PID The Unix paths remain unchanged.
tjb-tech
requested changes
Apr 25, 2026
Collaborator
tjb-tech
left a comment
There was a problem hiding this comment.
I would not merge this as-is. The main blocker is the new Windows PID discovery path depending on wmic:
- Microsoft documents
wmicas deprecated, and their current Windows client docs say it will be removed in a future Windows release. That makes it a poor new hard dependency for gateway lifecycle management. - Even before removal,
wmic process where commandline like ...is brittle for paths with quoting / escaping differences, especially around--workspacevalues on Windows.
The Unix-side intent here makes sense, but I think the Windows implementation should switch to a non-wmic process query path before merge. For example: PowerShell/CIM (Get-CimInstance Win32_Process) or another API-level enumeration path, plus tests around PID discovery / stop behavior.
Contributor
Author
|
BTW, what is our attitude towards third-party dependencies? Maybe using psutil is a better option considering cross-platform compatibility? |
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.
The ohmo gateway process management (start, find, stop) only worked on Unix-like systems. On Windows, all three operations fail:
ps, which doesn't exist on WindowsReplace each with a Windows-compatible path guarded by sys.platform:
The Unix paths remain unchanged.
Summary
What problem does this PR solve?
The ohmo gateway process lifecycle management (start_gateway_process, _pid_is_running, _iter_workspace_gateway_pids, stop_gateway_process) only works on Unix-like systems. On Windows, every operation fails:
What changed?
Added Windows-compatible paths for each operation, guarded by sys.platform == "win32":
The Unix paths remain completely unchanged.
Validation
uv run ruff check src tests scriptsuv run pytest -q(pre-existing failures on Windows unrelated to this change; ohmo/ directory has no test suite)cd frontend/terminal && npx tsc --noEmit(frontend not touched)Notes