Non-daemon thread causing EBADF in subprocess spawn
Resolved 💬 1 comment Opened Jul 10, 2025 by bukzor Closed Jul 11, 2025
Bug Description
Bug: claude-cli crashes with EBADF when Python subprocess creates non-daemon thread
Error:
Error: spawn EBADF
at ChildProcess.spawn (node:internal/child_process:421:11)
Minimal reproduction:
```python
import threading
import time
def worker():
while True:
time.sleep(0.001)
threading.Thread(target=worker, daemon=False).start()
Run: python repro.py in claude-cli
Expected: Script should run and claude-cli should continue normally
Actual: claude-cli crashes with EBADF error and becomes unusable
Root cause: Non-daemon threads prevent Python subprocess from exiting cleanly. When claude-cli tries to forcefully terminate the hanging subprocess, file
descriptors get corrupted, causing subsequent spawn operations to fail.
Workaround: Use daemon=True for threads, but this shouldn't crash the CLI.
Environment:
- claude-cli version: 1.0.44
- Python: 3.13.3
- OS: macOS (Darwin 24.5.0)
**Environment Info**
- Platform: darwin
- Terminal: tmux
- Version: 1.0.44
- Feedback ID: f09d4932-56c2-4b2a-a98b-6f75ae18b808
**Errors**
```json
[{"error":"Error: String not found in file. Failed to apply edit.\n at yT (file:///Users/buck/libexec/pnpm/global/5/.pnpm/@anthropic-ai+claude-code@1.0.44/node_modules/@anthropic-ai/claude-code/cli.js:1620:728)\n at tAA (file:///Users/buck/libexec/pnpm/global/5/.pnpm/@anthropic-ai+claude-code@1.0.44/node_modules/@anthropic-ai/claude-code/cli.js:1620:104)\n at Object.renderToolUseRejectedMessage (file:///Users/buck/libexec/pnpm/global/5/.pnpm/@anthropic-ai+claude-code@1.0.44/node_modules/@anthropic-ai/claude-code/cli.js:1630:4047)\n at HS2 (file:///Users/buck/libexec/pnpm/global/5/.pnpm/@anthropic-ai+claude-code@1.0.44/node_modules/@anthropic-ai/claude-code/cli.js:1947:2880)\n at zw (file:///Users/buck/libexec/pnpm/global/5/.pnpm/@anthropic-ai+claude-code@1.0.44/node_modules/@anthropic-ai/claude-code/cli.js:65:19802)\n at yP (file:///Users/buck/libexec/pnpm/global/5/.pnpm/@anthropic-ai+claude-code@1.0.44/node_modules/@anthropic-ai/claude-code/cli.js:67:42568)\n at _P (file:///Users/buck/libexec/pnpm/global/5/.pnpm/@anthropic-ai+claude-code@1.0.44/node_modules/@anthropic-ai/claude-code/cli.js:67:38117)\n at GL (file:///Users/buck/libexec/pnpm/global/5/.pnpm/@anthropic-ai+claude-code@1.0.44/node_modules/@anthropic-ai/claude-code/cli.js:67:38045)\n at vw (file:///Users/buck/libexec/pnpm/global/5/.pnpm/@anthropic-ai+claude-code@1.0.44/node_modules/@anthropic-ai/claude-code/cli.js:67:37899)\n at SW (file:///Users/buck/libexec/pnpm/global/5/.pnpm/@anthropic-ai+claude-code@1.0.44/node_modules/@anthropic-ai/claude-code/cli.js:67:34989)","timestamp":"2025-07-10T20:36:32.772Z"},{"error":"Error: Insufficient permissions for global npm install.\n at T9A (file:///Users/buck/libexec/pnpm/global/5/.pnpm/@anthropic-ai+claude-code@1.0.44/node_modules/@anthropic-ai/claude-code/cli.js:2088:977)\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n at async r01 (file:///Users/buck/libexec/pnpm/global/5/.pnpm/@anthropic-ai+claude-code@1.0.44/node_modules/@anthropic-ai/claude-code/cli.js:2098:43)\n at async file:///Users/buck/libexec/pnpm/global/5/.pnpm/@anthropic-ai+claude-code@1.0.44/node_modules/@anthropic-ai/claude-code/cli.js:2537:8923","timestamp":"2025-07-10T20:36:34.328Z"},{"error":"Error: Insufficient permissions for global npm install.\n at T9A (file:///Users/buck/libexec/pnpm/global/5/.pnpm/@anthropic-ai+claude-code@1.0.44/node_modules/@anthropic-ai/claude-code/cli.js:2088:977)\n at async r01 (file:///Users/buck/libexec/pnpm/global/5/.pnpm/@anthropic-ai+claude-code@1.0.44/node_modules/@anthropic-ai/claude-code/cli.js:2098:43)\n at async file:///Users/buck/libexec/pnpm/global/5/.pnpm/@anthropic-ai+claude-code@1.0.44/node_modules/@anthropic-ai/claude-code/cli.js:2537:8923","timestamp":"2025-07-10T20:37:59.860Z"},{"error":"Error: Language not supported while highlighting code, falling back to markdown: \n at TF (file:///Users/buck/libexec/pnpm/global/5/.pnpm/@anthropic-ai+claude-code@1.0.44/node_modules/@anthropic-ai/claude-code/cli.js:1478:1184)\n at file:///Users/buck/libexec/pnpm/global/5/.pnpm/@anthropic-ai+claude-code@1.0.44/node_modules/@anthropic-ai/claude-code/cli.js:1478:912\n at Array.map (<anonymous>)\n at CE (file:///Users/buck/libexec/pnpm/global/5/.pnpm/@anthropic-ai+claude-code@1.0.44/node_modules/@anthropic-ai/claude-code/cli.js:1478:903)\n at PS2 (file:///Users/buck/libexec/pnpm/global/5/.pnpm/@anthropic-ai+claude-code@1.0.44/node_modules/@anthropic-ai/claude-code/cli.js:1947:9731)\n at zw (file:///Users/buck/libexec/pnpm/global/5/.pnpm/@anthropic-ai+claude-code@1.0.44/node_modules/@anthropic-ai/claude-code/cli.js:65:19802)\n at yP (file:///Users/buck/libexec/pnpm/global/5/.pnpm/@anthropic-ai+claude-code@1.0.44/node_modules/@anthropic-ai/claude-code/cli.js:67:42568)\n at _P (file:///Users/buck/libexec/pnpm/global/5/.pnpm/@anthropic-ai+claude-code@1.
Note: Error logs were truncated.
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗