Skip to content

Bug: PTY exec_command collapses Unix signal termination into bare 128+signal exit code, indistinguishable from voluntary exit 137 #64525

Backlog

Description

@zsicheng0214

Summary

When a command executed through Codex's PTY/unified-exec path is terminated by a Unix signal (e.g., SIGKILL / SIGTERM), the model only receives a numeric exit_code of 128 + signal (e.g., 137 or 143) with no explicit signal metadata. A command killed externally by SIGKILL is therefore indistinguishable from a process that voluntarily ran exit 137.

(Related field discussion with full Core-95 context: #63850)

Root Cause (verified on main 065e18b)

  1. codex-rs/utils/pty/src/process.rs:35-49 (exit_code_from_status):

    pub(crate) fn exit_code_from_status(status: ExitStatus) -> i32 {
        if let Some(code) = status.code() {
            return code;
        }
    
        #[cfg(unix)]
        {
            use std::os::unix::process::ExitStatusExt;
            if let Some(signal) = status.signal() {
                return 128 + signal;
            }
        }
    
        -1
    }

    status.signal() is collapsed immediately into 128 + signal and discarded before the result reaches the tool-output formatter.

  2. codex-rs/core/src/exec.rs:771-795:
    The non-PTY exec path checks raw_output.exit_status.signal() (lines 773–779), returning SandboxErr::Signal(signal), while ExecToolCallOutput (line 790) carries only exit_code: i32 without a structured signal: Option<i32> field.

Steps to Reproduce

  1. Run Codex CLI 0.172.0 on Linux (x86_64) and execute two commands in a session:
    • Command A (voluntary exit): sh -c 'echo VOLUNTARY; exit 137'
    • Command B (killed by SIGKILL): sh -c 'echo SIGNALED; kill -9 $$'
  2. Compare the tool outputs surfaced to the model.

Expected Behavior

The tool result (and structured exec telemetry) should distinguish signal termination from normal exit — for example by preserving signal: Option<i32> alongside exit_code (or surfacing Process terminated by signal SIGKILL (exit code 137) vs Process exited with code 137).

Actual Behavior

Both commands surface as an undifferentiated 137 exit code. In our controlled 95-task evaluation of Codex CLI 0.172.0 (DeepSeek-V4.1-Flash in Docker), this ambiguity directly causes models to misclassify OOM/external SIGKILL kills as voluntary script exits (E1 signal-attribution tasks).

Environment

  • Codex CLI version: 0.172.0 (verified on main 065e18b)
  • OS: Debian Linux (x86_64, Docker)

Activity

  1. added
    bug
    CLI
    tool-calls
    on Nov 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    CLIbugtool-calls

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions