openai/codex · error · std::io::Error

terminal stderr suppression is already active

Error message

terminal stderr suppression is already active

What it means

install_suppression on macOS found the global stderr-suppression state already marked owner_active, so a second caller tried to claim suppression that another component still owns — a re-entrancy/double-install guard.

Solutions

  1. Ensure suppress_terminal_stderr is called only once per process lifetime
  2. Have the second caller reuse the existing suppression instead of erroring
  3. Release suppression (restore stderr) before installing again
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at codex-rs/tui/src/tui/terminal_stderr.rs:78 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of openai/codex@339751715c (2026-08-25). Data as JSON: /api/errors/60eb1c0a8a4d9fd2. Report an issue: GitHub.

Appendix: source

Thrown at codex-rs/tui/src/tui/terminal_stderr.rs:78

        }

        #[cfg(target_os = "macos")]
        {
            let mut state = lock_state()?;
            if !state.owner_active {
                suppress_locked(&mut state)?;
                state.owner_active = true;
            }
        }

        Ok(())
    }

    #[cfg(target_os = "macos")]
    fn install_suppression() -> io::Result<Self> {
        let mut state = lock_state()?;
        if state.owner_active {
            return Err(io::Error::new(
                io::ErrorKind::AlreadyExists,
                "terminal stderr suppression is already active",
            ));
        }
        suppress_locked(&mut state)?;
        state.owner_active = true;
        Ok(Self { active: true })
    }
}

impl Drop for TerminalStderrGuard {
    fn drop(&mut self) {
        if self.active {
            let _ = finish();
            self.active = false;
        }
    }
}

View on GitHub (pinned to 339751715c)