Skip to content

fix(status): catch OSError in os.kill(pid, 0) for Windows compatibility (salvage #12490)#14504

Merged
teknium1 merged 2 commits into
mainfrom
hermes/hermes-17b001fb
Apr 23, 2026
Merged

fix(status): catch OSError in os.kill(pid, 0) for Windows compatibility (salvage #12490)#14504
teknium1 merged 2 commits into
mainfrom
hermes/hermes-17b001fb

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Salvages #12490 by @phpoh onto current main.

On Windows, os.kill(nonexistent_pid, 0) raises OSError with WinError 87 instead of ProcessLookupError. Two sites in gateway/status.py caught only (ProcessLookupError, PermissionError) — any invalid PID check crashed on Windows, preventing gateway startup whenever a stale PID file survived.

Applied:

  • acquire_scoped_lock (line ~499): widened except to include OSError alongside the existing tuple
  • get_running_pid (line ~737): added a separate except OSError: continue clause AFTER except PermissionError: so PermissionError (an OSError subclass) still gets its dedicated branch first

The PR's original patch didn't apply cleanly because main refactored get_running_pid to iterate over primary/fallback records with a per-iteration try/except block. Functionally equivalent to @phpoh's original.

Closes #12490. Author attribution preserved via --author=.

phpoh and others added 2 commits April 23, 2026 03:04
On Windows, os.kill(nonexistent_pid, 0) raises OSError with WinError 87
("The parameter is incorrect") instead of ProcessLookupError. Without
catching OSError, the acquire_scoped_lock() and get_running_pid() paths
crash on any invalid PID check — preventing gateway startup on Windows
whenever a stale PID file survives from a prior run.

Adapted @phpoh's fix in #12490 onto current main. The main file was
refactored in the interim (get_running_pid now iterates over
(primary_record, fallback_record) with a per-iteration try/except),
so the OSError catch is added as a new except clause after
PermissionError (which is a subclass of OSError, so order matters:
PermissionError must match first).

Co-authored-by: phpoh <1352808998@qq.com>
@teknium1 teknium1 merged commit dab36d9 into main Apr 23, 2026
10 of 11 checks passed
@teknium1 teknium1 deleted the hermes/hermes-17b001fb branch April 23, 2026 10:05
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery labels Apr 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants