openai / openai/codex

Windows exec_command flattens cmd.exe nonzero exit codes to 1

Open
#45,917 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

app bug tool-calls windows-os
Dominant language
Rust
Stars
125k
Forks
19.4k
PR merge metrics
PR metrics pending

Description

Summary

On Windows Codex Desktop, commands run through the Codex command tool appear to collapse specific nonzero cmd.exe exit codes to 1.

This is distinct from the underlying Windows process behavior: running the same command through Node's child_process.spawnSync correctly reports the original exit status.

Environment

  • OS: Windows 11
  • Windows version observed from cmd /c ver: Microsoft Windows [Version 10.0.26200.9445]
  • Codex Desktop / ChatGPT Windows app
  • Shell in Codex task: PowerShell
  • Workspace path used for repro: C:\Users\pwval\NonOneDrive Environment Testing
  • Sandbox mode shown in task context: workspace-write

Reproduction Steps

In a Codex Desktop task on Windows, run:

cmd /c exit /b 42

Observed Codex tool result:

Process exited with code 1

Then run an independent check through Node:

node -e "const {spawnSync}=require('child_process'); const r=spawnSync('cmd.exe',['/c','exit /b 42'],{encoding:'utf8'}); console.log(JSON.stringify({status:r.status,signal:r.signal,stdout:r.stdout,stderr:r.stderr}));"

Observed Node result:

{"status":42,"signal":null,"stdout":"","stderr":""}

Expected Behavior

The Codex command runner should report the actual Windows process exit code, 42, or otherwise preserve enough detail to distinguish different nonzero exit statuses.

Actual Behavior

The Codex command runner reports exit code 1 for cmd /c exit /b 42.

Additional Context

Other command-runner behavior appears improved compared with earlier local testing:

cmd /c echo HI

now correctly returns:

HI

A workspace write test also now succeeds:

cmd /c "echo test>codex_write_test.txt"
Get-Content -Raw codex_write_test.txt

returns:

test

So stdout capture and workspace writes appear to work in this environment, but precise nonzero exit-code propagation still appears broken.

This may be related to existing Windows command-runner/tool-call issues, but I did not find an exact duplicate for exit-code flattening:

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing cmd /c exit /b 42 on Windows and tracing the command runner's exit-status handling; the issue provides a Node spawnSync comparison showing the expected status. Done means the Codex command runner preserves status 42 and distinguishes it from other nonzero exits, while existing stdout and workspace-write behavior remains intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, shell
Domain
cli, operating-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.