{"record":{"id":"593ee720f5e41dd5","repo":"BigPizzaV3/CodexPlusPlus","slug":"cannot-wait-for-windows-process-id-process-id-on","errorCode":null,"errorMessage":"cannot wait for Windows process id {process_id} on this platform","messagePattern":"cannot wait for Windows process id (.+?) on this platform","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/launcher.rs","lineNumber":3183,"sourceCode":"\n    unsafe {\n        let handle = OpenProcess(\n            PROCESS_TERMINATE | PROCESS_QUERY_LIMITED_INFORMATION,\n            false,\n            process_id,\n        )\n        .with_context(|| format!(\"failed to open Windows process id {process_id}\"))?;\n        let terminate_result = TerminateProcess(handle, 1);\n        let _ = CloseHandle(handle);\n        terminate_result\n            .with_context(|| format!(\"failed to terminate Windows process id {process_id}\"))?;\n    }\n    Ok(())\n}\n\n#[cfg(not(windows))]\nasync fn wait_for_windows_process_id(process_id: u32) -> anyhow::Result<()> {\n    anyhow::bail!(\"cannot wait for Windows process id {process_id} on this platform\")\n}\n\n#[cfg(not(windows))]\nasync fn terminate_windows_process_id(process_id: u32) -> anyhow::Result<()> {\n    anyhow::bail!(\"cannot terminate Windows process id {process_id} on this platform\")\n}\n\nfn launch_status(\n    status: &str,\n    message: &str,\n    debug_port: u16,\n    helper_port: u16,\n    app_dir: &Path,\n) -> LaunchStatus {\n    LaunchStatus {\n        status: status.to_string(),\n        message: message.to_string(),\n        started_at_ms: now_ms(),","sourceCodeStart":3165,"sourceCodeEnd":3201,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/launcher.rs#L3165-L3201","documentation":"`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.","triggerScenarios":"Calling wait_for_windows_process_id (directly or via launcher flows that wait on a spawned/tracked process) on macOS or Linux builds.","commonSituations":"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.","solutions":["Only call this function (and its callers) behind #[cfg(windows)] on Windows builds","Implement a platform-specific equivalent (e.g. waitpid or polling `ps`) for non-Windows targets","Refactor the calling flow to a trait/abstraction with per-platform implementations"],"exampleFix":"// before\nasync fn wait_for_windows_process_id(process_id: u32) -> anyhow::Result<()> {\n    anyhow::bail!(\"cannot wait for Windows process id {process_id} on this platform\")\n}\n// after\n#[cfg(unix)]\nasync fn wait_for_windows_process_id(_process_id: u32) -> anyhow::Result<()> {\n    Ok(()) // no-op on unix: windows-only PID cannot be waited here\n}","handlingStrategy":"validation","validationCode":"// call only on windows\n#[cfg(windows)]\nlet _ = launcher.wait_for_windows_process_id(pid).await;","typeGuard":"fn can_wait_windows_pid() -> bool { cfg!(windows) }","tryCatchPattern":"if cfg!(windows) {\n    launcher.wait_for_windows_process_id(pid).await?;\n} else {\n    tracing::debug!(\"skipping windows pid wait on this platform\");\n}","preventionTips":["Gate windows-only process APIs behind cfg(windows) in callers","Use a platform-abstraction trait for process lifecycle ops","Add non-Windows unit tests that assert stub errors rather than crash","Document platform support matrix in README"],"tags":["rust","cross-platform","windows","process-wait"],"backgroundTag":"unsupported-platform","analyzedSha":"b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6","analyzedAt":"2026-09-19T23:35:21.129Z","contentChangedAt":"2026-09-19T23:35:21.129Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}