fix(gateway): #8978 resolve Windows startup crash caused by os.kill(0…#9024
Closed
dip8989 wants to merge 1 commit into
Closed
fix(gateway): #8978 resolve Windows startup crash caused by os.kill(0…#9024dip8989 wants to merge 1 commit into
dip8989 wants to merge 1 commit into
Conversation
…by os.kill(0) WinError 87
2 tasks
zhanggttry
added a commit
to zhanggttry/hermes-agent
that referenced
this pull request
Apr 22, 2026
…g to file reads - os.kill(pid, 0) on Windows raises OSError (WinError 87) for non-existent PIDs instead of ProcessLookupError. Catch OSError everywhere to prevent crash on Windows process-existence checks. - Path.read_text() and open() default to gbk on Chinese Windows. Add explicit encoding='utf-8' to all file reads to prevent UnicodeDecodeError when config files or skill manifests contain non-ASCII characters. Files changed: - gateway/run.py, gateway/status.py (os.kill + read_text) - hermes_cli/*.py (read_text + open) - tools/*.py (read_text) Closes: NousResearch#13587 NousResearch#5762 NousResearch#7835 NousResearch#9024
Collaborator
Contributor
|
Thanks for the detailed write-up and the fix, @dip8989! The underlying WinError 87 crash from Automated hermes-sweeper review
Closing as implemented on main. |
1 task
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.
…) WinError 87
What does this PR do?
Resolves #8978
🚨 Architectural Defect
A critical OS-compatibility issue was identified in
gateway/status.py. Theget_running_pid()function relies onos.kill(pid, 0)for process existence checking. While this is a standard POSIX convention, passing a0signal on Windows immediately raises anOSError (WinError 87: The parameter is incorrect). This caused the gateway daemon to crash unconditionally during its startup health-check sequence on Windows machines.🛠️ Mitigation Strategy
Implemented a robust, zero-dependency cross-platform branching logic:
nt): Interfaced directly withctypes.windll.kernel32to useOpenProcessandGetExitCodeProcess. This safely determines process vitality (STILL_ACTIVE) without triggering signal errors or spawning heavy subshells.os.kill(pid, 0)check.OSErrorto the exception catch block to gracefully handle any underlying permission/access anomalies on both operating systems, preventing future hard crashes.📈 System Impact
psutil), maintaining a lightweight core.