[BUG] Hung ps -A -o pid= -o ppid= child processes accumulate until the per-user process limit is exhausted (macOS)

Status Open
Reported on v2.1.218
Maintainer reply None cached
Activity 1 comment · opened Jul 23, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

Each claude process spawns its internal process-tree probe ps -A -o pid= -o ppid= every ~2–3 s. The children never exit (state S+, empty wchan) and accumulate — we observed 2,210 hung ps processes across 5 sessions (~50 per session per 2 minutes). Once kern.maxprocperuid (2666) is reached, every fork on the machine fails with EAGAIN: git pushes, Claude Code's own Bash tool, background tasks and monitors.

What Should Happen?

The internal process-tree probe (ps -A -o pid= -o ppid=) should complete and be reaped within milliseconds, regardless of how many processes exist on the system. Spawned ps children should never accumulate: Claude Code should drain the child's stdout concurrently (or kill the child on timeout instead of abandoning it), so a large process table cannot make ps block forever on a full pipe. Long-running sessions must not exhaust kern.maxprocperuid — once that limit is hit, every fork on the machine fails (git, Claude Code's own Bash tool, background tasks), which is effectively a self-inflicted denial of service on the host.

Error Messages/Logs

Steps to Reproduce

not sure

Claude Model

Not sure / Multiple models

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.218

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Warp

Additional Information

Verification: ps -p <hung-pids> -o pid,ppid,wchan,args shows ps -A -o pid= -o ppid= with the claude binary as direct parent. Not caused by statusline/hooks (parent would be their shell).

Hypothesis: the spawned ps's stdout pipe isn't drained (or the spawn is abandoned on timeout without kill). When total system process count grows large enough that the output exceeds the pipe buffer, ps blocks on write forever — and each hung instance grows the process table, making the next one hang too (self-amplifying).

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗