Repository navigation
Claude Code no longer dies at launch on macOS with "EINVAL: invalid argument, kqueue" - #166
Open
DrewBradfordXYZ wants to merge 1 commit into
Open
DrewBradfordXYZ wants to merge 1 commit into
DrewBradfordXYZ wants to merge 1 commit into
Conversation
…rgument, kqueue" AgentSystemLabs#130 gave the login shell /dev/null as stdin while the rc files run, then reopened /dev/tty before the agent command. macOS kqueue refuses /dev/tty, and Claude Code (Bun) watches stdin with kqueue, so every Claude agent exited 1 on startup. The stdin shim now records the PTY's own device path in NEBULA_PANE_TTY before the rc files run, and the launch line reopens stdin from that path (then unsets it). rc files still see a non-TTY stdin, so the Iris autostart fix from AgentSystemLabs#130 holds; its e2e test now also asserts the agent's stdin is not /dev/tty. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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.
Since #130, every Claude Code agent on macOS exits at launch with
error: EINVAL: invalid argument, kqueue(exit 1). Agents now start again, and the Iris autostart fix from #130 still holds.Contents: 🐛 Symptom · 🔍 Cause · ✅ Fix · 🧪 Proof ·⚠️ Risk
🐛 Symptom
exited.main(a00b760) with Claude Code 2.1.296, on a fresh daemon with no user rc files.🔍 Cause
/dev/nullas stdin while the rc files run, so Iris-style autostarts leave the shell alone.exec </dev/ttybefore the agent command./dev/tty(EVFILT_READon the controlling-terminal alias returnsEINVAL). Claude Code is a Bun binary that watches stdin with kqueue, so it throws on startup./dev/ttys00N) as stdin, starts normally.claudeis a shell function that only checks[ -t 0 ], and/dev/ttypasses that.✅ Fix
NEBULA_PANE_TTY=$(tty), falling back to/dev/ttyifttyfails, then hands the shell/dev/nullas before./dev/tty, and unsets the variable before the agent runs, so no child inherits it.TERM/COLORTERMare restated as before.nebula_core::envbeside the others (PANE_TTY).🧪 Proof
The test change is small: two lines added to the existing Iris e2e test.
create_agent_survives_rc_autostart_that_execs_on_tty_stdinnow also records the fakeclaude's stdin device, and asserts it is not/dev/tty./dev/ttyline: it fails (left: "/dev/tty"). It passes with the fix.Real-CLI A/B, using a throwaway e2e test (not committed) that runs
nebula daemonwithSHELL=/bin/zsh, launches the realclaude2.1.296, attaches and reads the pane for 20s:maina00b760EINVAL: invalid argument, kqueue,SessionExited exit_code=1~0.2–0.6s after createmain+ this PR🟢 Low.
ttyfallback: ifttycan't name stdin, the shim falls back to/dev/tty, which is the old behaviour./dev/ttythere.🤖 Generated with Claude Code