Repository navigation
Keep Claude Code alive when a Codex subagent starts - #129
Merged
Merged
Conversation
The Codex helper reads the login shell's PATH with `$SHELL -l -i`, and it runs inside Claude Code's terminal. An interactive zsh with a controlling terminal takes over the terminal's foreground while it runs, about half a second on every Codex turn. Claude Code was a background job on its own terminal for that time, and when it touched the terminal then, it died, taking the helper with it. Since #124 this happened on any turn. The login shell now starts in a session of its own (setsid), without a controlling terminal, so it can't take the terminal from anyone. This also covers the --mcp-title server, which runs in the same terminal.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
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.
Starting a Codex subagent sometimes killed the Claude Code session that ran it. The subagent then reported "Codex failed: the helper stopped without an answer", and Claude Code exited without a message.
Cause
claudiu --acpruns inside Claude Code's terminal. To findnpx, it reads the login shell's PATH with$SHELL -l -i -c …(with_login_path, since #124). An interactive zsh that has a controlling terminal takes over the terminal's foreground while it runs, about half a second on every Codex turn. For that time Claude Code is a background job on its own terminal. When it touched the terminal during that window, it died, and the helper died with it.Fix
path_from_shellstarts the shell in a session of its own (setsidinpre_exec), so it has no controlling terminal to take. The fix is in the shared function, so it also covers the--mcp-titleserver, which runs in the same terminal and can reach the login PATH throughgh.Proof
zsh -l -iwithout a terminal still prints the full PATH, Homebrew directories included.the_login_shell_runs_without_this_processs_terminalfails without the fix (the shell's process group equals the test's) and passes with it.cargo clippy --locked --all-targets -- -D warningsis clean, andcargo test --lockedpasses 519.Risk
A startup file that needs a terminal now runs without one, and an interactive shell with no terminal prints warnings to stderr, which is discarded. The PATH is read the same way. To undo, revert this commit.