macOS desktop app leaks PTY masters (/dev/ptmx) until system-wide PTY exhaustion (ENXIO)

Open 💬 1 comment Opened Jun 12, 2026 by helgastogova

Environment

  • Claude desktop app (macOS): 1.11847.5
  • macOS: 26.4 (Darwin 25.4.0, arm64)
  • Running Claude Code sessions inside the desktop app

Bug

The Claude desktop app's main process leaks PTY master file descriptors. After ~2 days of regular agent use (sessions using the Bash tool / terminals), the main Claude process holds 500 open /dev/ptmx descriptors:

$ lsof -nP | grep "/dev/ptmx" | awk '{print $1}' | sort | uniq -c | sort -rn | head -3
 500 Claude        # /Applications/Claude.app/Contents/MacOS/Claude (single PID)
   6 turbo
   5 stable

$ sysctl kern.tty.ptmx_max
kern.tty.ptmx_max: 511

macOS caps concurrent PTYs at kern.tty.ptmx_max = 511 (default), so the leak exhausts the system-wide PTY pool. Once exhausted, every openpty() on the machine fails with ENXIO:

$ python3 -c 'import pty; pty.openpty()'
OSError: out of pty devices

$ script -q /tmp/x.log echo hello
script: openpty: Device not configured

User-visible impact

Anything on the machine that allocates a PTY breaks, far outside Claude itself. How we hit it: git push started failing in an unrelated repo because the lefthook (v2.x) git-hooks manager allocates a PTY per hook job — every pre-push job died instantly with device not configured, blocking the push. script, tmux, new terminal multiplexer panes, etc. fail the same way.

Restarting the Claude desktop app releases all 500 descriptors and everything recovers — until the leak builds up again.

Expected

PTY masters allocated for Bash tool / terminal sessions should be closed when the command or session ends. The count of held /dev/ptmx descriptors should track live sessions (a handful), not grow monotonically into the hundreds.

Repro sketch

  1. Use Claude Code in the macOS desktop app heavily for a day or two (many Bash tool invocations across sessions).
  2. Watch lsof -nP | grep /dev/ptmx | grep -c Claude grow and never shrink.
  3. When it approaches kern.tty.ptmx_max, any openpty() on the system fails with ENXIO ("Device not configured").

View original on GitHub ↗

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