[BUG] CLI Crashes with posix_spawn EAGAIN Error Due to Recursive pgrep Calls
Environment
- Platform (select one):
- [x] Anthropic API ?
- [ ] AWS Bedrock
- [ ] Google Vertex AI
- [ ] Other:
- Claude CLI version:
1.0.56 (Claude Code) - Operating System:
Darwin 24.5.0 Darwin Kernel Version 24.5.0: Tue Apr 22 19:53:27 PDT 2025; root:xnu-11417.121.6~2/RELEASE_ARM64_T6041 arm64 - Terminal:
alacritty 0.15.1 (0c405d5)alsokitty
Bug Description
After using claude-code for a bit while the model is working and I'm doing something else it gets into a infinite recursion around calling pgrep. This appears to happen during subprocess calls that involve pgrep. It looks like the code recursively spawns processes without proper throttling or reuse, eventually hitting system process limits (EAGAIN). This may be related to repeated tool invocations or checks for running processes.
Steps to Reproduce
- I haven't quite figured out how this happens
Expected Behavior
The CLI should avoid hitting system resource limits. Ideally, subprocess spawning (e.g. pgrep) should be rate-limited or reused rather than recursively or rapidly spawned.
Actual Behavior
The CLI fails with posix_spawn errors (underlying error: Resource temporarily unavailable) and terminates unexpectedly. The crash happens when system process limits are reached, likely due to excessive pgrep subprocesses.
reproduction steps:
- have CC run a process that hangs
- double tap escape to interrupt (in vim mode)
- it gets into the issue.
I'll provide a test command
happens on a different terminal as well
Ghostty 1.1.2
Version
- version: 1.1.2
- channel: stable
Build Config
- Zig version: 0.13.0
- build mode : builtin.OptimizeMode.ReleaseFast
- app runtime: apprt.Runtime.none
- font engine: font.main.Backend.coretext
- renderer : renderer.Metal
- libxev : main.Backend.kqueue
This is (apparently) caused by installing proctools ps:
https://github.com/anthropics/claude-code/issues/4316#issuecomment-3188347086
I don't have access to my subscription to confirm at this time. If this is the case it helps to know this to either remove it or make sure proctools isn't available to CC, Thanks. The issue should still stay open regardless IMO so that it's solved by CC
workaround for me:
brew uninstall proctools
I want to fix this issue as soon as posible.
I haven't proctools installed on my machine, and I get into this error
This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.
I don't have access to Claude code this moment to verify if it's still an issue but if you are still seeing it bump this to prevent auto-closure of the issue.
This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.