[Bug] Frequent EAGAIN and EBADF errors in process spawning on macOS

Resolved 💬 9 comments Opened Dec 26, 2025 by cyberops7 Closed Feb 25, 2026

Bug Description
Claude code is crashing FREQUENTLY with EBADF and/or EBADF process spawning errors. This has happened on both Claude 2.0.76 and 2.0.75, on macOS 15.7.x and 26.2.

Environment Info

  • Platform: darwin
  • Terminal: ghostty
  • Version: 2.0.75
  • Feedback ID: 2f56fa66-4ccd-4c65-b920-3b635b2366d3

I have already tried a lot of different troubleshooting suggestions, but nothing has helped, so far. This has happened across multiple sessions, plans, etc.

❯ ulimit -a
-t: cpu time (seconds)              unlimited
-f: file size (blocks)              unlimited
-d: data seg size (kbytes)          unlimited
-s: stack size (kbytes)             8176
-c: core file size (blocks)         0
-v: address space (kbytes)          unlimited
-l: locked-in-memory size (kbytes)  unlimited
-u: processes                       6000
-n: file descriptors                8192

-n used to be set to 256, but increasing it to 8192 has not made any difference.

Errors

[]

Initial error was:

EAGAIN: resource temporarily unavailable, posix_spawn '/opt/homebrew/bin/pgrep'
      path: "/opt/homebrew/bin/pgrep",
   syscall: "spawn pgrep",
     errno: -35,
 spawnargs: [ "-P", 586 ],
      code: "EAGAIN"

      at spawn (node:child_process:667:35)
      at spawn (node:child_process:14:39)
      at <anonymous> (/$bunfs/root/claude:190:41503)
      at RoR (/$bunfs/root/claude:190:41996)
      at <anonymous> (/$bunfs/root/claude:190:42231)
      at forEach (1:11)
      at $ (/$bunfs/root/claude:190:42170)
      at emit (node:events:98:22)
      at #maybeClose (node:child_process:766:16)

662 |     var file = this.spawnfile = options.file, spawnargs;
663 |     if (options.args === @undefined)
664 |       spawnargs = this.spawnargs = [];
665 |     else
666 |       validateArray(options.args, "options.args"), spawnargs = this.spawnargs = options.args;
667 |       if (this.#handle = Bun.spawn({

but more recently it is:

Error: spawn EBADF
    at ChildProcess.spawn (node:internal/child_process:420:11)
    at spawn (node:child_process:753:9)
    at file:///Users/david/.nvm/versions/node/v22.16.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:240:45818
    at fp1 (file:///Users/david/.nvm/versions/node/v22.16.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:240:46313)
    at file:///Users/david/.nvm/versions/node/v22.16.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:240:46546
    at Array.forEach (<anonymous>)
    at ChildProcess.X (file:///Users/david/.nvm/versions/node/v22.16.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:240:46481)
    at ChildProcess.emit (node:events:518:28)
    at ChildProcess.emit (node:domain:489:12)
    at maybeClose (node:internal/child_process:1101:16) {
  errno: -9,
  code: 'EBADF',
  syscall: 'spawn'
}

View original on GitHub ↗

This issue has 9 comments on GitHub. Read the full discussion on GitHub ↗