claude-code - 💡(How to fix) Fix [Bug] pgrep fork bomb causing session hang with repeated command execution [3 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#50885Fetched 2026-04-20 12:10:22
View on GitHub
Comments
3
Participants
3
Timeline
9
Reactions
0
Author
Timeline (top)
labeled ×4commented ×3mentioned ×1subscribed ×1
RAW_BUFFERClick to expand / collapse

Bug Description There is a consistent bug I have had for monthes of claude code. It consistently fork bombs my session with the command 'pgrep', I do not know the conditions which trigger this, it may have to do with sub-shells, but how hard would it be, to just check if pgrep has been run more than 20 times repeatedly, or something to that effect. This persistent bug has survived through many iterations of claude code, and I am disappointed it hasn't been addressed.

Environment Info

  • Platform: darwin
  • Terminal: iTerm.app
  • Version: 2.1.114
  • Feedback ID: 9c409506-8023-43d3-a003-faadcd6aa9b8

Errors Complete crash of my iTerm server, no ability to spawn new shells until I force-kill in Activity Monitor. It exhausts my user process limit, and claude becomes a ghost process I need to force quit. A fork bomb effectively.

extent analysis

TL;DR

Implement a rate limit or a counter to prevent excessive execution of the pgrep command to mitigate the fork bomb issue.

Guidance

  • Investigate the conditions under which the pgrep command is triggered to understand the root cause of the issue.
  • Consider adding a check to limit the number of times pgrep can be executed within a certain time frame (e.g., more than 20 times) to prevent the fork bomb.
  • Review the claude code to identify potential sub-shell usage that may be contributing to the issue.
  • Explore options for increasing the user process limit to prevent exhaustion, but be cautious of potential security implications.

Example

No code snippet can be provided without more context, but a simple rate limiting mechanism could be implemented using a counter and a timer.

Notes

The exact conditions triggering the pgrep command are unknown, making it challenging to provide a definitive solution. The proposed workaround may not completely resolve the issue but can help mitigate its effects.

Recommendation

Apply a workaround, such as implementing a rate limit or counter for the pgrep command, as the root cause of the issue is unclear and a more comprehensive solution may require further investigation.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING