fix(gateway): handle OSError/SystemError from os.kill on Windows#7552
Closed
Arcadia-1 wants to merge 3 commits into
Closed
fix(gateway): handle OSError/SystemError from os.kill on Windows#7552Arcadia-1 wants to merge 3 commits into
Arcadia-1 wants to merge 3 commits into
Conversation
On Windows, `os.kill(pid, 0)` for stale/exited PIDs raises `OSError` (WinError 87: "The parameter is incorrect") or `SystemError` instead of the Unix-standard `ProcessLookupError`. This causes gateway restart failures after non-clean shutdowns, as stale PID/lock files cannot be cleared. Add `OSError` and `SystemError` to except clauses in all 6 call sites across gateway/status.py, gateway/run.py, hermes_cli/gateway.py, hermes_cli/profiles.py, and tools/process_registry.py. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…msvcrt memory_tool.py imports fcntl unconditionally at module level, which fails on Windows (no fcntl module). This prevents the entire memory tool from loading, disabling persistent memory for all Windows users. Replace the top-level fcntl import with a platform check: use msvcrt.locking on Windows and fcntl.flock on Unix. The import is deferred to the _file_lock context manager so neither module is required at import time on the other platform. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
On Windows with Git Bash terminals, file paths passed to vision_analyze use Unix-style mount points (e.g. /h/Hermes/...) which Path.is_file() cannot resolve. This causes "Invalid image source" errors and makes the agent loop endlessly trying alternative approaches. Convert /x/... paths to X:\... on Windows before the is_file() check. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
4 tasks
Collaborator
4 tasks
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 Windows compatibility bugs that break core functionality:
os.kill(pid, 0)crashes on Windows — raisesOSError(WinError 87) orSystemErrorinstead ofProcessLookupErrorfor stale PIDs. Gateway cannot restart after non-clean shutdown.memory_tool.pyfails to load on Windows — unconditionalimport fcntlat module level. Persistent memory (MEMORY.md / USER.md) is completely unavailable for all Windows users.vision_analyzefails on Windows with Git Bash paths — paths like/h/Hermes/file.pngfrom terminal tool output are not valid Windows paths.Path.is_file()returns False, causing "Invalid image source" errors and agent loops.Changes
os.kill exception handling (5 files, 6 call sites)
Added
OSErrorandSystemErrorto except clauses:gateway/status.pyget_running_pid(),acquire_scoped_lock()gateway/run.pystart_gateway()— wait for old process exithermes_cli/gateway.pystop_profile_gateway()— wait for process exithermes_cli/profiles.py_check_gateway_running(),_stop_gateway_process()tools/process_registry.py_is_pid_alive()memory_tool fcntl → cross-platform (1 file)
import fcntl_file_lock()now usesmsvcrt.lockingon Windows,fcntl.flockon Unixvision_tools Git Bash path conversion (1 file)
/x/...paths toX:\...on Windows beforePath.is_file()check/drive-letter/restpatternTest plan
import tools.memory_toolsucceeds/h/Hermes/hermes-agent/AGENTS.mdcorrectly resolves toH:\Hermes\hermes-agent\AGENTS.mdhermes gatewayconnects to Feishu + Weixin with all tools availableos.name == "nt"🤖 Generated with Claude Code