mirror of
https://github.com/openai/codex.git
synced 2026-02-01 22:47:52 +00:00
Avoid setpgid for inherited stdio on macOS (#8691)
## Summary - avoid setting a new process group when stdio is inherited (keeps child in foreground PG) - keep process-group isolation when stdio is redirected so killpg cleanup still works - prevents macOS job-control SIGTTIN stops that look like hangs after output ## Testing - `cargo build -p codex-cli` - `GIT_CONFIG_GLOBAL=/dev/null GIT_CONFIG_NOSYSTEM=1 CARGO_BIN_EXE_codex=/Users/denis/Code/codex/codex-rs/target/debug/codex /opt/homebrew/bin/timeout 30m cargo test -p codex-core -p codex-exec` ## Context This fixes macOS sandbox hangs for commands like `elixir -v` / `erl -noshell`, where the child was moved into a new process group while still attached to the controlling TTY. See issue #8690. ## Authorship & collaboration - This change and analysis were authored by **Codex** (AI coding agent). - Human collaborator: @seeekr provided repro environment, context, and review guidance. - CLI used: `codex-cli 0.77.0`. - Model: `gpt-5.2-codex (xhigh)`. Co-authored-by: Eric Traut <etraut@openai.com>
This commit is contained in:
@@ -66,10 +66,11 @@ pub(crate) async fn spawn_child_async(
|
||||
|
||||
#[cfg(unix)]
|
||||
unsafe {
|
||||
let set_process_group = matches!(stdio_policy, StdioPolicy::RedirectForShellTool);
|
||||
#[cfg(target_os = "linux")]
|
||||
let parent_pid = libc::getpid();
|
||||
cmd.pre_exec(move || {
|
||||
if libc::setpgid(0, 0) == -1 {
|
||||
if set_process_group && libc::setpgid(0, 0) == -1 {
|
||||
return Err(std::io::Error::last_os_error());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user