Skip to content

fix(windows): handle stale PID locks and TUI console input#790

Merged
qin-ctx merged 1 commit intovolcengine:mainfrom
Bortlesboat:fix/windows-pid-lock-and-tui
Mar 20, 2026
Merged

fix(windows): handle stale PID locks and TUI console input#790
qin-ctx merged 1 commit intovolcengine:mainfrom
Bortlesboat:fix/windows-pid-lock-and-tui

Conversation

@Bortlesboat
Copy link
Copy Markdown
Contributor

Summary

Fix two Windows-specific issues that prevent normal operation on Windows:

  1. Stale PID lock recovery (process_lock.py): os.kill(pid, 0) raises OSError (WinError 87: "The parameter is incorrect") on Windows for stale or invalid PIDs, instead of ProcessLookupError as on Unix. This prevented the server from reclaiming lock files left by crashed processes, blocking startup with no recovery path other than manually deleting the .openviking.pid file. Fixes [Feature]: Stale RocksDB LOCK detection for local-mode multi-session safety (Windows) #650.

  2. TUI console input (rust_cli.py): os.execv() on Windows does not truly replace the current process — CPython's MSVC implementation spawns a child process instead. This breaks console handle inheritance, which prevents the Rust TUI (crossterm) from receiving keyboard input. Replaced all three os.execv() call sites with a helper that uses subprocess.call() on Windows to properly inherit console handles. Fixes [Bug]: ov tui cannot be used on Windows systems. #587.

Changes

  • openviking/utils/process_lock.py: Add except OSError clause to _is_pid_alive() to handle Windows-specific error codes for stale PIDs.
  • openviking_cli/rust_cli.py: Extract _exec_binary() helper that dispatches to subprocess.call() on Windows and os.execv() on Unix.

Testing

  • PID lock fix: Reproduced on Windows 11 (Python 3.12) — server crashed, left stale .openviking.pid, subsequent startup failed with OSError: [WinError 87]. After fix, stale lock is correctly reclaimed.
  • TUI fix: The os.execv()subprocess.call() pattern is a well-known Windows workaround for console applications (CPython docs).
  • ruff check passes on both files.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 19, 2026

CLA assistant check
All committers have signed the CLA.

Fix two Windows-specific issues:

1. process_lock: os.kill(pid, 0) raises OSError (WinError 87) on
   Windows for stale/invalid PIDs instead of ProcessLookupError.
   This prevented the server from reclaiming stale lock files after
   a crash, blocking startup with no clear recovery path. (volcengine#650)

2. rust_cli: os.execv() on Windows does not replace the current
   process — CPython's MSVC implementation spawns a child instead.
   This breaks console handle inheritance, preventing the Rust TUI
   from receiving keyboard input. Replace with subprocess.call()
   on Windows to properly inherit console handles. (volcengine#587)
@Bortlesboat Bortlesboat force-pushed the fix/windows-pid-lock-and-tui branch from 79d33c1 to e9f285d Compare March 20, 2026 01:20
@qin-ctx qin-ctx self-assigned this Mar 20, 2026
@qin-ctx qin-ctx merged commit 9884497 into volcengine:main Mar 20, 2026
1 check passed
@github-project-automation github-project-automation bot moved this from Backlog to Done in OpenViking project Mar 20, 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.

[Feature]: Stale RocksDB LOCK detection for local-mode multi-session safety (Windows) [Bug]: ov tui cannot be used on Windows systems.

3 participants