fix: use Port with closed stdin to prevent Codex CLI hang#34
Merged
joshrotenberg merged 1 commit intomainfrom Mar 31, 2026
Merged
fix: use Port with closed stdin to prevent Codex CLI hang#34joshrotenberg merged 1 commit intomainfrom
joshrotenberg merged 1 commit intomainfrom
Conversation
Codex CLI hangs when stdin is inherited from the parent process (waiting for input that never comes). The Rust codex-wrapper solved this with Stdio::null(). Replaced System.cmd with Port-based execution that redirects stdin from /dev/null via shell wrapper. Handles shell escaping for args. Closes #33
joshrotenberg
added a commit
that referenced
this pull request
Apr 10, 2026
The non-streaming execute path was fixed in #34, but the streaming paths in Exec.stream/2 and ExecResume.stream/2 still opened a raw Port with stdin inherited from the parent. Codex CLI 0.118+ reads stdin at startup and blocks forever on the open-but-empty pipe, causing streams to hang until the internal 300s safety timeout. Extract the shell-wrapping logic from Command.run_with_closed_stdin into a shared Command.shell_cmd_args/3 helper that both execute and streaming paths now use. Streaming opts out of the 2>&1 stderr merge so stderr flows to the parent without contaminating NDJSON on stdout. Verified against codex-cli 0.119.0: Exec.stream/2 now completes in ~13s with the expected thread.started / turn.started / item.completed / turn.completed events instead of hanging on the safety timeout. Closes #37
3 tasks
joshrotenberg
added a commit
that referenced
this pull request
Apr 10, 2026
The non-streaming execute path was fixed in #34, but the streaming paths in Exec.stream/2 and ExecResume.stream/2 still opened a raw Port with stdin inherited from the parent. Codex CLI 0.118+ reads stdin at startup and blocks forever on the open-but-empty pipe, causing streams to hang until the internal 300s safety timeout. Extract the shell-wrapping logic from Command.run_with_closed_stdin into a shared Command.shell_cmd_args/3 helper that both execute and streaming paths now use. Streaming opts out of the 2>&1 stderr merge so stderr flows to the parent without contaminating NDJSON on stdout. Verified against codex-cli 0.119.0: Exec.stream/2 now completes in ~13s with the expected thread.started / turn.started / item.completed / turn.completed events instead of hanging on the safety timeout. Closes #37
joshrotenberg
added a commit
that referenced
this pull request
Apr 10, 2026
The non-streaming execute path was fixed in #34, but the streaming paths in Exec.stream/2 and ExecResume.stream/2 still opened a raw Port with stdin inherited from the parent. Codex CLI 0.118+ reads stdin at startup and blocks forever on the open-but-empty pipe, causing streams to hang until the internal 300s safety timeout. Extract the shell-wrapping logic from Command.run_with_closed_stdin into a shared Command.shell_cmd_args/3 helper that both execute and streaming paths now use. Streaming opts out of the 2>&1 stderr merge so stderr flows to the parent without contaminating NDJSON on stdout. Verified against codex-cli 0.119.0: Exec.stream/2 now completes in ~13s with the expected thread.started / turn.started / item.completed / turn.completed events instead of hanging on the safety timeout. Closes #37
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #33. Redirects stdin from /dev/null via Port so Codex doesn't hang.