Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

Preserve Windows sandbox runner launch errors (#49261)

zm-oaif35a0fdc5d5f
diff --git a/codex-rs/windows-sandbox-rs/src/elevated/runner_client.rs b/codex-rs/windows-sandbox-rs/src/elevated/runner_client.rs
index 6f688f166d..d09aa02d53 100644
--- a/codex-rs/windows-sandbox-rs/src/elevated/runner_client.rs
+++ b/codex-rs/windows-sandbox-rs/src/elevated/runner_client.rs
@@ -409,11 +409,12 @@ pub(crate) fn spawn_runner_transport(
&mut pi,
)
};
+ // Preserve the failure code before SetErrorMode can overwrite it.
+ let spawn_error = (spawn_res == 0).then(|| unsafe { GetLastError() });
unsafe {
SetErrorMode(previous_error_mode);
}
- if spawn_res == 0 {
- let err = unsafe { GetLastError() };
+ if let Some(err) = spawn_error {
return Err(RunnerLogonError { code: err }.into());
}
// Keep the process pinned through the entire startup handshake. Pipes close