[0.159] Backport Windows console suppression for 0.159.2 (#49385)

Backport #49164 and #49308 onto the content commit of 0.159.1 to
suppress Windows console flashing reported in #48074. The two
cherry-picks applied without conflicts; no other fixes are included.
Cargo remains at the release-branch content version, 0.0.0.

Validation: `git diff --check` passes. Native Windows execution has not
been validated on this exact candidate. Keep this PR in draft pending
required review and a focused Windows smoke test: from a non-elevated
PowerShell host with workspace-write and the unelevated sandbox, verify
built-ins and external whoami.exe, cmd.exe, Git and nested PowerShell
terminate with expected output, both with a matching managed daemon and
with --no-daemon, without visible console flashes. Record exact
binary/candidate SHA, CLI and daemon versions, CODEX_HOME,
configuration, exit codes and durations.

The alpha.2 reports in
https://github.com/openai/codex/issues/48074#issuecomment-5898123863 and
https://github.com/openai/codex/issues/48074#issuecomment-5897958690
conflict on execution safety; they do not establish a causal regression
or validate this exact backport. Do not publish 0.159.2 until the
evidence and required checks/review are complete.

---------

Co-authored-by: Eric Traut <etraut@openai.com>
This commit is contained in:
andrewgu-oai
2026-10-02 19:04:39 +00:00
committed by Andrew Gu
co-authored by Eric Traut
parent c46b6c7048
commit 94cd1062e9
47 changed files with 386 additions and 75 deletions
+1
View File
@@ -9,6 +9,7 @@ readme = "README.md"
workspace = true
[dependencies]
codex-utils-process = { workspace = true }
anyhow = { workspace = true }
chrono = { workspace = true }
codex-file-system = { workspace = true }
+1 -10
View File
@@ -41,16 +41,7 @@ fn spawn_git_command(command: &mut Command) -> Option<(Child, KillGitProcessTree
.stderr(Stdio::piped());
#[cfg(windows)]
let (child, job) = match JobObject::create()
.and_then(|job| job.spawn_contained(command).map(|child| (child, job)))
{
Ok((child, job)) => (child, Some(job)),
Err(_) => {
// A failed contained spawn leaves CREATE_SUSPENDED on the command.
command.creation_flags(0);
(command.spawn().ok()?, None)
}
};
let (child, job) = JobObject::spawn_background(command).ok()?;
#[cfg(not(windows))]
let child = command.spawn().ok()?;
+1 -2
View File
@@ -2,7 +2,6 @@ use std::ffi::OsStr;
use std::ffi::OsString;
use std::path::Path;
use std::path::PathBuf;
use std::process::Command;
use codex_protocol::shell_environment::scrub_non_inheritable_env_vars;
@@ -130,7 +129,7 @@ where
args_vec.push(OsString::from(arg.as_ref()));
}
let command_string = build_command_string(&args_vec);
let mut command = Command::new("git");
let mut command = codex_utils_process::background_command("git");
command.current_dir(dir);
if let Some(envs) = env {
for (key, value) in envs {