Skip to content

fix(utils): handle WinError 11 in process_lock._is_pid_alive#854

Merged
qin-ctx merged 2 commits intovolcengine:mainfrom
Bortlesboat:fix/windows-winerror-11-process-lock
Mar 22, 2026
Merged

fix(utils): handle WinError 11 in process_lock._is_pid_alive#854
qin-ctx merged 2 commits intovolcengine:mainfrom
Bortlesboat:fix/windows-winerror-11-process-lock

Conversation

@Bortlesboat
Copy link
Contributor

Summary

Fixes #842. On Windows 11, os.kill(pid, 0) can raise OSError with WinError 11 (ERROR_BAD_FORMAT) for stale PIDs, in addition to the already-known WinError 87. This causes the server to crash on startup when a stale lock file exists.

  • Catches broad OSError on Windows only (sys.platform == "win32") and returns False (pid not alive)
  • Re-raises OSError on non-Windows platforms to preserve existing behavior
  • Documents both known WinError codes (11 and 87) in comments

Test plan

  • Verified the fix logic handles both WinError 11 and WinError 87
  • Confirmed non-Windows platforms re-raise unexpected OSError
  • Tested on Windows 11 with stale lock file from killed process

On Windows, os.kill(pid, 0) can raise OSError with WinError 11
(ERROR_BAD_FORMAT) in addition to WinError 87 for stale/invalid PIDs.
The previous catch-all OSError handler also silently swallowed errors
on non-Windows platforms. This change:

- Documents both known WinError codes (11, 87) in the comment
- Restricts the broad OSError catch to Windows only (re-raises on
  other platforms to avoid masking real errors)

Fixes volcengine#842

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link

Failed to generate code suggestions for PR

@qin-ctx qin-ctx merged commit 95636ab into volcengine:main Mar 22, 2026
5 checks passed
@github-project-automation github-project-automation bot moved this from Backlog to Done in OpenViking project Mar 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[Bug]: Windows 11 部署出现: OSError WinError 11 in process_lock._is_pid_alive breaks server startup

2 participants