[BUG] Claude app (macOS) leaks pty/ptmx handles, exhausting kern.tty.ptmx_max and breaking all new terminals

Resolved 💬 2 comments Opened Jun 16, 2026 by leaf76 Closed Jun 20, 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?

Over a long-running Claude session, the Claude process steadily accumulates open
master pseudo-terminal handles (/dev/ptmx) and never releases them. They build up past
the macOS limit (kern.tty.ptmx_max = 511), after which the OS can no longer allocate a
pty for ANY new terminal.

Once this happens, every terminal app fails to start a shell:

  • iTerm2: misleading dialog "A session ended very soon after starting. Check that the

command in profile 'Default' is correct."

  • Warp: the real cause -> "Shell process could not start! openpty failed: ENXIO: No

such device or address"

It is NOT a shell-config issue (.zshrc etc. are fine). lsof confirms Claude holds the
vast majority of ptys:

$ sysctl -n kern.tty.ptmx_max
511
$ lsof -n | awk '$NF=="/dev/ptmx"{print $1}' | sort | uniq -c | sort -rn
469 Claude <-- leaked masters
41 tmux
21 iTerm2
1 iTermServer
(total 532, over the 511 limit)

Other resources were fine (kern.maxfiles=122880, num_files~10758, ~650 procs), so it is
specifically a ptmx leak by Claude.

What Should Happen?

Claude should close each pseudo-terminal (release the /dev/ptmx master) when the
corresponding shell/agent/tool invocation finishes, so the open-pty count stays bounded
and never exhausts the system pty limit.

Error Messages/Logs

Warp:
  Shell process could not start!
  openpty failed: ENXIO: No such device or address

iTerm2:
  A session ended very soon after starting. Check that the command in profile "Default" is correct.

Steps to Reproduce

  1. Use the Claude app on macOS for an extended session with many shell/agent/tool calls.
  2. Periodically run: lsof -n | grep -c /dev/ptmx

Observe the count held by the Claude process grow monotonically and never drop after
sub-tasks finish.

  1. When total open ptys reach kern.tty.ptmx_max (511 here), open a new window/tab in any

terminal app (iTerm2, Warp, Terminal.app).

  1. The new session fails instantly:
  • Warp: openpty failed: ENXIO: No such device or address
  • iTerm2: "A session ended very soon after starting..."
  1. Quitting/relaunching the Claude app releases the ptys and terminals work again.

Claude Model

None

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

Claude 1.12603.1 (3df4fd) 2026-06-11T16:57:36.000Z

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

iTerm2

Additional Information

Diagnostic:
sysctl -n kern.tty.ptmx_max
lsof -n | awk '$NF=="/dev/ptmx"{print $1}' | sort | uniq -c | sort -rn

Workaround: quit and relaunch the Claude app, or reboot.
Impact: breaks ALL terminal apps system-wide, not just one. iTerm2's error is misleading;
Warp surfaces the true openpty/ENXIO cause.

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗