[PR #151] [CLOSED] fix(pty): Detect immediate child exit on Windows to prevent hangs #166

Closed
opened 2026-02-27 10:22:29 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/mikeyobrien/ralph-orchestrator/pull/151
Author: @mikeyobrien
Created: 2/3/2026
Status: Closed

Base: mainHead: fix-windows-pty-hang


📝 Commits (2)

  • 63042ef chore: auto-commit before merge (loop primary)
  • f2f28a7 fix(pty): Detect immediate child exit on Windows to prevent hangs

📊 Changes

7 files changed (+4088 additions, -0 deletions)

View changed files

📝 crates/ralph-adapters/src/pty_executor.rs (+39 -0)
mobile-styles.patch (+104 -0)
rook-dashboard-live.html (+667 -0)
rook-dashboard-mobile.html (+1020 -0)
rook-dashboard-prototype.html (+1786 -0)
specs/rook-dashboard-architecture.md (+340 -0)
specs/rook-dashboard.spec.md (+132 -0)

📄 Description

Problem

On Windows, when the backend process (e.g., `claude`) fails to start (e.g., not in PATH), the PTY reader thread hangs indefinitely. This happens because:

  1. The slave PTY is dropped after spawning
  2. The reader thread blocks on `reader.read()` waiting for output
  3. If the child process exited immediately (command not found), no EOF is sent
  4. The reader thread hangs forever, blocking the main loop

This results in `ralph run` appearing to hang with no output.

Solution

Add a Windows-specific check after spawning the child process to detect if it exited immediately. If the process exits with a non-zero code within 100ms of spawning, we return a clear error message indicating the backend command failed to start.

The fix is applied to both:

  • `run_observe()` - Used for headless/autonomous mode
  • `run_observe_streaming()` - Used for TUI mode

Testing

  • Code compiles successfully with `cargo check --package ralph-adapters`
  • The fix is gated behind `#[cfg(windows)]` so it only affects Windows builds
  • On non-Windows platforms, behavior is unchanged

Fixes #150


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/mikeyobrien/ralph-orchestrator/pull/151 **Author:** [@mikeyobrien](https://github.com/mikeyobrien) **Created:** 2/3/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix-windows-pty-hang` --- ### 📝 Commits (2) - [`63042ef`](https://github.com/mikeyobrien/ralph-orchestrator/commit/63042ef2ef8658f701cf810c3ef359343651f179) chore: auto-commit before merge (loop primary) - [`f2f28a7`](https://github.com/mikeyobrien/ralph-orchestrator/commit/f2f28a7e25740d01c3dc8dc2bc69a70f256ac640) fix(pty): Detect immediate child exit on Windows to prevent hangs ### 📊 Changes **7 files changed** (+4088 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `crates/ralph-adapters/src/pty_executor.rs` (+39 -0) ➕ `mobile-styles.patch` (+104 -0) ➕ `rook-dashboard-live.html` (+667 -0) ➕ `rook-dashboard-mobile.html` (+1020 -0) ➕ `rook-dashboard-prototype.html` (+1786 -0) ➕ `specs/rook-dashboard-architecture.md` (+340 -0) ➕ `specs/rook-dashboard.spec.md` (+132 -0) </details> ### 📄 Description ## Problem On Windows, when the backend process (e.g., &#96;claude&#96;) fails to start (e.g., not in PATH), the PTY reader thread hangs indefinitely. This happens because: 1. The slave PTY is dropped after spawning 2. The reader thread blocks on &#96;reader.read()&#96; waiting for output 3. If the child process exited immediately (command not found), no EOF is sent 4. The reader thread hangs forever, blocking the main loop This results in &#96;ralph run&#96; appearing to hang with no output. ## Solution Add a Windows-specific check after spawning the child process to detect if it exited immediately. If the process exits with a non-zero code within 100ms of spawning, we return a clear error message indicating the backend command failed to start. The fix is applied to both: - &#96;run_observe()&#96; - Used for headless/autonomous mode - &#96;run_observe_streaming()&#96; - Used for TUI mode ## Testing - Code compiles successfully with &#96;cargo check --package ralph-adapters&#96; - The fix is gated behind &#96;#[cfg(windows)]&#96; so it only affects Windows builds - On non-Windows platforms, behavior is unchanged Fixes #150 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 10:22:29 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ralph-orchestrator#166
No description provided.