BigPizzaV3/CodexPlusPlus · error · anyhow::Error

cannot terminate Windows process id

Error message

cannot terminate Windows process id {process_id} on this platform

What it means

`terminate_windows_process_id` is Windows-only; on non-Windows targets the cfg(not(windows)) stub bails with this message. Killing a Windows PID (via TerminateProcess/TinyNuke-style APIs) simply cannot be done from macOS/Linux, so the operation is refused rather than silently ignored.

Solutions

  1. Gate the termination call path with #[cfg(windows)] and skip it on other platforms
  2. Implement a non-Windows equivalent only if the target PID actually refers to a local process (kill with SIGTERM/SIGKILL)
  3. Refactor to a platform abstraction trait with per-OS terminate implementations

Example fix

// before
#[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")
}
// after
#[cfg(not(windows))]
async fn terminate_windows_process_id(_process_id: u32) -> anyhow::Result<()> {
    tracing::warn!("terminate_windows_process_id is a no-op on this platform");
    Ok(())
}
Defensive patterns

Strategy: validation

Validate before calling

if !cfg!(windows) {
    tracing::warn!("terminate_windows_process_id unsupported here; skipping");
    return Ok(());
}

Type guard

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

Try / catch

match launcher.terminate_windows_process_id(pid).await {
    Ok(()) => {},
    Err(e) if e.to_string().contains("on this platform") => tracing::warn!("termination skipped: {e}"),
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Calling terminate_windows_process_id (or a launcher cleanup flow that uses it to kill a tracked process) on a macOS or Linux build.

Common situations: Running debug-relaunch cleanup on a dev machine that is not Windows; tests that exercise process termination flows on non-Windows CI.

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/c87e98f7df7e39b2. Report an issue: GitHub.

Appendix: source

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

            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(),
        debug_port: Some(debug_port),
        helper_port: Some(helper_port),
        codex_app: Some(app_dir.to_string_lossy().to_string()),
        aumid: crate::app_paths::packaged_app_user_model_id(app_dir),
    }

View on GitHub (pinned to b1ed92e5e4)