codex cli hangs while waiting for additional input from stdin
Key points
- A
codex execrun produced no visible output for more than five minutes. Inspection showed that the intended executable was running. (Source: our own measurement, 2026-09-07) - The captured output contained
Reading additional input from stdin.... Closing stdin with< /dev/nullresolved the same symptom in an independent run that day. (Source: our own measurement, 2026-09-07) - Running outside the target repository produced a separate error, even with stdin closed. Its output also began with the stdin message. (Source: our own measurement, 2026-09-07)
- A prompt delimiter was unreliable as a completion signal because the CLI echoed the prompt before responding. The recorded workflow checked the trailing
tokens usedoutput instead. (Source: our own measurement, 2026-09-07)
A silent run looked like an executable problem
The failing invocation passed a long prompt directly to codex exec and selected the read-only sandbox. It then remained without visible output for more than five minutes. The immediate question was whether the process had encountered an executable-selection problem already described in an earlier troubleshooting note.
That earlier note concerned background execution picking up an old Homebrew installation, version 0.20.0, and hanging. The visible symptom was similar enough to make that explanation a candidate: a background command had started, but the expected response had not appeared.
The process inspection did not support that explanation in this case. The command used to inspect the running process was:
ps aux | grep codex
The process listing showed the intended nvm-managed executable. It also showed CPU usage of 1.8%, which the record treated as evidence that the process remained alive. A version check returned 0.153.4.
These observations separated the current failure from the older installation problem. They established which executable was running; they did not yet explain why the response was absent. Continuing to treat the old Homebrew installation as the cause would have ignored the process evidence already available.
The useful distinction was between a familiar appearance and a verified match. “No output” described the symptom. It did not identify which of the recorded failure modes had occurred.
(Source: our own measurement, 2026-09-07)
The captured line identified an input wait
The output file contained only this line:
Reading additional input from stdin...
That message changed the diagnosis. The prompt had been supplied as a command-line argument, but the process was still waiting for additional input through stdin.
An stdin wait is a state in which a process remains waiting for input from its standard input stream.
The recorded cause was a non-TTY stdin in automated execution, including agent execution, cron, or a pipe. In the observed behavior, passing the prompt as an argument did not prevent Codex from waiting for additional input on that stream. The investigation attributed the wait to stdin handling, rather than prompt length or model choice.
This explained why the original invocation could look complete to the caller while still leaving the process waiting. The prompt argument was present. The executable was the intended one. Neither observation established that the input stream had been closed.
The captured line was therefore more informative than the absence of an answer. It named the operation the process was waiting on. The process listing answered “Which executable is running?” while the output answered “What is it waiting for?” Both checks were necessary to distinguish this incident from the previous executable-selection issue.
The record’s lesson was to inspect the process and the beginning of its output before applying an explanation from a previous incident. Here, the only captured line pointed directly to the missing input handling.
Closing stdin resolved the recorded hang
The corrective action was to close stdin explicitly with < /dev/null. The command recorded in the material’s updated invocation guidance was:
codex exec --ephemeral --sandbox read-only "$(cat prompt.txt)" < /dev/null
The part that addressed the hang was the input redirection. It made the stdin handling explicit alongside the prompt argument.
An independent run on the same date encountered the same symptom and confirmed that adding < /dev/null resolved it. That run used CLI version 0.153.2, while the original investigation had reported 0.153.4. The material therefore contains both the initial diagnosis and a separate confirmation of the corrective action.
The existing guidance to use an absolute executable path for background jobs and cron remained applicable. Selecting the intended executable and closing stdin addressed separate problems. The stdin finding did not invalidate the earlier executable-selection finding; it showed why that earlier finding did not explain this particular run.
The --ephemeral option in the example has a separate history. A later update required it because invocations without that option saved conversations in the local session history and surfaced them in the application’s recent-conversation list. That update concerned history retention. The recorded stdin remedy remained < /dev/null.
Keeping these purposes distinct matters when reading the final command. Its flags and redirection combine operational requirements that were added for different reasons. The material does not attribute the stdin fix to --ephemeral or to the read-only sandbox.
(Source: our own measurement, 2026-09-07; recorded history-handling update, 2026-09-24)
The same opening message also appeared before a different failure
Closing stdin did not resolve every unsuccessful invocation. Another recorded run started outside the repository, from a scratch directory, and terminated immediately even with < /dev/null present.
Its output was:
Reading additional input from stdin...
Not inside a trusted directory and --skip-git-repo-check was not specified.
The first line resembled the earlier hang. The second line identified a different failure: the working directory did not satisfy the repository check.
This is the limit of treating the first line as a diagnosis by itself. In the original incident, it was the only output left by a still-running process. In the directory incident, it preceded an explicit error and immediate termination. The shared opening message did not make the two outcomes equivalent.
The recorded correction was to run the command from the target repository’s root. Prompt files and output files could remain in /tmp; the execution directory was the part that needed to change.
Although the error text mentions --skip-git-repo-check, the documented remedy was to change the working directory. The material does not report testing that flag as the solution.
The distinction is directly useful when checking a failed run: read the output beyond the familiar stdin line and establish whether the process is waiting or has already exited. In this record, those observations separate an open-input problem from a directory error without requiring either diagnosis to explain both.
Lessons: verify input, execution context, and completion separately
The follow-up observations extended the investigation beyond getting the process to start responding. A wrapper also needed to recognize when the response was complete.
The recorded workflow initially risked searching for a delimiter included in the prompt:
=====ARTICLE2=====
That was unreliable because Codex echoed the supplied prompt before producing its response. Searching the output for a string already present in that prompt could report completion during the echo stage. The recorded replacement was to check for the trailing tokens used output.
Request size was another separate observation. A request for two English articles totaling 2,400 words ended with exit 144, recorded as signal termination. Asking for one article at a time was stable in the follow-up runs. The material does not establish what caused the signal termination, so that outcome cannot be assigned to the stdin issue.
For a comparable failure, the checks supported by this record are concrete: inspect the running executable, read the captured output, close stdin explicitly, and execute from the target repository root. If a wrapper watches output for completion, check whether its search string also appears in the prompt being echoed.
Each check answers a different question. Executable inspection identifies the program actually launched. Input redirection addresses the recorded wait. The working directory addresses the explicit repository error. Completion detection distinguishes prompt echo from the end of the response.
The central lesson is to preserve those distinctions. A silent command, a terminated command, and a prematurely reported completion can interrupt the same workflow while leaving different evidence. In this case, reading that evidence made the stdin fix specific and kept later errors from being mistaken for its recurrence.
(Source: our own measurement, 2026-09-07)
Root Cause is written while shipping small software products — you can see them at TechAthletes.