Windows command execution can hang indefinitely when descendant processes inherit stdout/stderr handles, causing agent turns to become stuck forever
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- rust
- Domain
- cli, operating-systems
Research direction
Start in the shared Codex process-execution/app-server layer described by the issue and reproduce the hang with dotnet test on Windows. Investigate process-tree cleanup, inherited stdout/stderr handles, and Windows Job Objects, then verify that timeout or cancellation returns promptly without waiting indefinitely for EOF or leaving descendant processes running.
Written by the indexing model from the issue text.
Description
What version of Codex CLI is running?
codex-cli 0.145.0-alpha.18
What subscription do you have?
Pro
Which model were you using?
gpt-5.6-sol
What platform is your computer?
Microsoft Windows NT 10.0.26100.0 x64
What terminal emulator and version are you using (if applicable)?
No response
Codex doctor report
What issue are you seeing?
Codex command execution can remain active indefinitely on Windows after the launched parent process has exited or been terminated by its configured timeout, causing the agent to get stuck forever.
I experience this bug regularly and have to manually interrupt the turn and tell the agent it got stuck. Orphaned worker processes also accumulate on the system. Any build system, test runner, compiler daemon, development server, or script that spawns descendants may trigger the same problem.
This occurs when the command spawns descendant processes that inherit the command’s stdout/stderr pipe handles. Codex appears to wait for EOF from those pipes before completing the command execution. Because the descendants still hold the write ends open, EOF never arrives—even though the original process is no longer running and the shell-command timeout has expired.
This affects the shared Codex process-execution/app-server layer. It is observable in both the CLI and Codex Desktop because Desktop delegates command execution to app-server.
dotnet test is a reliable reproducer because it can spawn persistent MSBuild worker nodes, but the underlying issue applies to any program that leaves handle-inheriting descendants running.
What steps can reproduce the bug?
Reliable reproduction using .NET/MSBuild
- Open a repository containing a .NET test project.
- Ask Codex to execute a command such as:
dotnet test path\to\Tests.csproj -c Release - Configure a finite shell-command timeout.
- Have the command time out, be cancelled, or otherwise cause the parent
dotnet testprocess to exit while its spawned MSBuild worker nodes remain running. - Inspect the process list and observe descendant processes resembling:
dotnet.exe ... MSBuild.dll /nodemode:1 ... - Observe the Codex command execution after the parent process has exited.
General reproduction condition
The same failure should be reproducible with any command that:
- Spawns a descendant process.
- Allows that descendant to inherit stdout or stderr.
- Exits or is terminated while the descendant remains alive.
What is the expected behavior?
When a command reaches its timeout or is cancelled, Codex should:
- Terminate the entire process tree associated with the command.
- Close or detach all harness-owned stdout/stderr pipe handles deterministically.
- Return a timeout or cancellation result promptly.
- Avoid making command completion depend indefinitely on EOF from surviving descendants.
A configured timeout should be an upper bound, apart from a short and separately bounded cleanup interval.
When a spawned process ends but child processes continue to hold parent pipe handles indefinitely, the agent should ideally be notified so that it can choose to either continue waiting for the child processes or evaluate the situation and take appropriate action in the case where there are orphaned processes that need to be forcibly terminated.
Additional information
On Windows, consider running each command inside a Job Object configured to terminate contained processes when the job is closed, such as with JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE.
On timeout, cancellation, client disconnection, or app-server shutdown:
- Terminate or close the command’s Job Object so the complete process tree is stopped.
- Close the server’s command-specific pipe handles explicitly.
- Bound any stream-drain or process-cleanup wait.
- Return the command result without waiting indefinitely for EOF from uncontrolled descendants.
It may also be worth auditing handle inheritance so only intended child processes receive stdout/stderr handles, but that may not be viable.
- Dominant language
- Rust
- Stars
- 125k
- Forks
- 19.5k
- Avg merge
- 1m
- Merged PRs (30d)
- 1k
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from openai/codex
-
enhancement remote
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
bug CLI windows-os
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
macOS sandbox blocks hw.optional.arm64 sysctl, causing Flutter to misdetect Apple Silicon as x64 Openbug CLI sandbox
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
bug CLI TUI
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
-
CLI config enhancement skills
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
kwakseongjae/auto-hwp#319 ·
-
area:cli bug filter-quality good first issue priority:medium
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
bevyengine/bevy#25861 ·
-
comp-datalake
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
ClickHouse/ClickHouse#121222 ·
-
A-linter
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
oxc-project/oxc#26863 ·