fix(AI-CLI-if5u): resolve real tty device before backgrounding agent stdin - #147
Merged
sergeiwallace merged 1 commit intoSep 15, 2026
Merged
Conversation
…stdin commit 6f0127b redirected a backgrounded agent's stdin from the literal /dev/tty alias. On macOS, kqueue refuses to poll an fd opened through that alias path (ttyname_r resolves it to /dev/tty again rather than a real device) -- Bun-compiled claude then crashes with EINVAL on launch. Resolve the controlling terminal's actual device path via `tty` first and redirect from that instead, falling back to the literal /dev/tty when resolution fails. Root cause corroborated externally: oven-sh/bun#41504. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PFi83LbqMTznL3DW2sVm9d
sergeiwallace
deleted the
wt/ai-cli-1/AI-CLI-ai-c-launcher-fails-start-bun-if5u
branch
September 15, 2026 02:33
sergeiwallace
pushed a commit
that referenced
this pull request
Sep 15, 2026
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PFi83LbqMTznL3DW2sVm9d
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.
Summary
ai c 1failed to launch/resume a CC session on macOS: Claude Code (Bun-compiled) crashed withEINVAL: invalid argument, kqueueafter commit 6f0127b (fix(AI-CLI-1rk1): retain pi's terminal stdin when backgrounded, add consecutive-failure circuit breaker #145) started redirecting a backgrounded agent's stdin from the literal/dev/ttyalias./dev/ttyalias path (ttyname_rresolves it back to/dev/ttyitself rather than a real device). Externally confirmed: oven-sh/bun#41504.ttybefore backgrounding, and redirect from that resolved path. Falls back to the literal/dev/ttywhen resolution fails, same as before.Test plan
test_given_terminal_stdin_when_agent_is_backgrounded_then_resolved_device_path_is_preferredadded, confirmed RED on unfixed code, GREEN after the fix.ruff check/ruff format --checkpass.tests/test_session_launch_shell_resolution.py): 11 passed.test_public_repo_hygiene.py,test_native_deps.py,test_session_reload_mtime.py,test_stale_session_reaper.py[zsh]) are pre-existing/environmental — reproduced identically on the pre-fix commit, unrelated to this change (the[zsh]supervisor failures trace to this worktree's unapproved.envrc, tracked separately as AI-CLI-np2i).ai c 1re-launch on the real host to close the loop (orchestrator/user follow-up, not verifiable in this sandbox).docs/bugs/ai-cli-if5u-kqueue-dev-tty-einval.md has the full root-cause writeup.