mirror of
https://github.com/openai/codex.git
synced 2026-11-20 22:40:37 +00:00
Detach Unix hook commands from the controlling terminal (#43876)
## Why Shell startup code that accesses the controlling terminal can stop a hook on background terminal I/O, preventing the hook command from running. ## What changed Use `detach_from_tty` before executing Unix hook commands to avoid inheriting the controlling terminal while preserving process-group cleanup. ## Testing Add a Unix regression test that runs under a controlling terminal and uses `BASH_ENV` to invoke `stty` during shell startup. Verify that the hook completes successfully and produces the expected output. GitOrigin-RevId: 231125d4b169fb1bd828e3f8e96476a13bd25d26
This commit is contained in:
@@ -222,7 +222,12 @@ pub(crate) async fn run_command(
|
||||
.kill_on_drop(true);
|
||||
|
||||
#[cfg(unix)]
|
||||
command.process_group(0);
|
||||
// Keep process-group cleanup without inheriting the controlling terminal, where
|
||||
// shell startup can otherwise stop the hook on background terminal I/O.
|
||||
// SAFETY: detach_from_tty only performs async-signal-safe process setup.
|
||||
unsafe {
|
||||
command.pre_exec(codex_utils_pty::process_group::detach_from_tty);
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
let mut process_tree_job = JobObject::create().ok();
|
||||
|
||||
Reference in New Issue
Block a user