BigPizzaV3/CodexPlusPlus · error · anyhow::Error

cannot wait for Windows process id

Error message

cannot wait for Windows process id {process_id} on this platform

What it means

`wait_for_windows_process_id` is only implemented for Windows targets. On any other platform the cfg(not(windows)) stub immediately bails, telling the caller that blocking on a Windows process PID is impossible there. It exists so the code compiles cross-platform while making the limitation explicit at runtime.

Solutions

  1. Only call this function (and its callers) behind #[cfg(windows)] on Windows builds
  2. Implement a platform-specific equivalent (e.g. waitpid or polling `ps`) for non-Windows targets
  3. Refactor the calling flow to a trait/abstraction with per-platform implementations

Example fix

// before
async fn wait_for_windows_process_id(process_id: u32) -> anyhow::Result<()> {
    anyhow::bail!("cannot wait for Windows process id {process_id} on this platform")
}
// after
#[cfg(unix)]
async fn wait_for_windows_process_id(_process_id: u32) -> anyhow::Result<()> {
    Ok(()) // no-op on unix: windows-only PID cannot be waited here
}
Defensive patterns

Strategy: validation

Validate before calling

// call only on windows
#[cfg(windows)]
let _ = launcher.wait_for_windows_process_id(pid).await;

Type guard

fn can_wait_windows_pid() -> bool { cfg!(windows) }

Try / catch

if cfg!(windows) {
    launcher.wait_for_windows_process_id(pid).await?;
} else {
    tracing::debug!("skipping windows pid wait on this platform");
}

Prevention

When it happens

Trigger: Calling wait_for_windows_process_id (directly or via launcher flows that wait on a spawned/tracked process) on macOS or Linux builds.

Common situations: Developing/debugging the manager on macOS or Linux and hitting a code path meant for Windows takeover; cross-platform test suites exercising process-wait logic.

Understand the failure class

Background: "unsupported platform" / "not supported on this platform" errors: what they mean and how to fix them — this error's family across 47 libraries.

Related errors


AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19). Data as JSON: /api/errors/593ee720f5e41dd5. Report an issue: GitHub.

Appendix: source

Thrown at crates/codex-plus-core/src/launcher.rs:3183

    unsafe {
        let handle = OpenProcess(
            PROCESS_TERMINATE | PROCESS_QUERY_LIMITED_INFORMATION,
            false,
            process_id,
        )
        .with_context(|| format!("failed to open Windows process id {process_id}"))?;
        let terminate_result = TerminateProcess(handle, 1);
        let _ = CloseHandle(handle);
        terminate_result
            .with_context(|| format!("failed to terminate Windows process id {process_id}"))?;
    }
    Ok(())
}

#[cfg(not(windows))]
async fn wait_for_windows_process_id(process_id: u32) -> anyhow::Result<()> {
    anyhow::bail!("cannot wait for Windows process id {process_id} on this platform")
}

#[cfg(not(windows))]
async fn terminate_windows_process_id(process_id: u32) -> anyhow::Result<()> {
    anyhow::bail!("cannot terminate Windows process id {process_id} on this platform")
}

fn launch_status(
    status: &str,
    message: &str,
    debug_port: u16,
    helper_port: u16,
    app_dir: &Path,
) -> LaunchStatus {
    LaunchStatus {
        status: status.to_string(),
        message: message.to_string(),
        started_at_ms: now_ms(),

View on GitHub (pinned to b1ed92e5e4)