{"record":{"id":"ce6433c695e49599","repo":"openai/codex","slug":"sethandleinformation-failed-for-stdio-handle","errorCode":null,"errorMessage":"SetHandleInformation failed for stdio handle: {}","messagePattern":"SetHandleInformation failed for stdio handle: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"codex-rs/windows-sandbox-rs/src/process.rs","lineNumber":138,"sourceCode":"    let mut si: STARTUPINFOEXW = std::mem::zeroed();\n    si.StartupInfo.cb = std::mem::size_of::<STARTUPINFOEXW>() as u32;\n    // Some processes (e.g., PowerShell) can fail with STATUS_DLL_INIT_FAILED\n    // if lpDesktop is not set when launching with a restricted token.\n    // Point explicitly at the interactive desktop or a private desktop.\n    si.StartupInfo.lpDesktop = desktop.startup_info_desktop();\n    match stdio {\n        Some((stdin_h, stdout_h, stderr_h)) => {\n            si.StartupInfo.dwFlags |= STARTF_USESTDHANDLES;\n            si.StartupInfo.hStdInput = stdin_h;\n            si.StartupInfo.hStdOutput = stdout_h;\n            si.StartupInfo.hStdError = stderr_h;\n            let mut inherited_handles = vec![stdin_h, stdout_h];\n            if !inherited_handles.contains(&stderr_h) {\n                inherited_handles.push(stderr_h);\n            }\n            for &handle in &inherited_handles {\n                if SetHandleInformation(handle, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT) == 0 {\n                    return Err(anyhow!(\n                        \"SetHandleInformation failed for stdio handle: {}\",\n                        GetLastError()\n                    ));\n                }\n            }\n            attrs.set_handle_list(inherited_handles)?;\n        }\n        None => {\n            ensure_inheritable_stdio(&mut si.StartupInfo)?;\n        }\n    }\n    si.lpAttributeList = attrs.as_mut_ptr();\n\n    let creation_flags = CREATE_UNICODE_ENVIRONMENT | EXTENDED_STARTUPINFO_PRESENT | console_flags;\n    let ok = CreateProcessAsUserW(\n        h_token,\n        std::ptr::null(),\n        cmdline.as_mut_ptr(),","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/openai/codex/blob/339751715c64496cb86246bfb3935f40e309dd3d/codex-rs/windows-sandbox-rs/src/process.rs#L120-L156","documentation":"Error \"SetHandleInformation failed for stdio handle: {}\" thrown in openai/codex.","triggerScenarios":"Thrown at codex-rs/windows-sandbox-rs/src/process.rs:138 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"339751715c64496cb86246bfb3935f40e309dd3d","analyzedAt":"2026-08-25T05:35:09.876Z","schemaVersion":2},"datasetVersion":"2026-08-25T06:17:31.827Z"}