Claude desktop app leaks PTY file descriptors (/dev/ptmx), exhausting macOS system limit and blocking new terminal windows
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?
The Claude desktop app (macOS) leaks PTY file descriptors by opening /dev/ptmx for each Bash tool call but never closing them. After extended use with many Bash tool invocations, the number of open PTY handles grows to 500+, exhausting the macOS system limit of 511 (kern.tty.ptmx_max).
Once the limit is hit, macOS Terminal.app can no longer open new windows and reports:
[forkpty: Device not configured]
[未能创建新的进程和打开伪终端(pseudo-tty)。]
Diagnosis via lsof /dev/ptmx | awk '{print $1}' | sort | uniq -c | sort -rn:
505 Claude
2 Electron
1 Terminal
kern.tty.ptmx_max: 511 — 505 of 511 PTY slots consumed by the Claude process.
What Should Happen?
PTY file descriptors should be released when each Bash tool call completes. The Claude app should not accumulate hundreds of open /dev/ptmx handles across tool calls in a session.
Error Messages/Logs
macOS Terminal.app when trying to open a new window:
[forkpty: Device not configured]
[未能创建新的进程和打开伪终端(pseudo-tty)。]
`lsof /dev/ptmx` output (505 entries, all Claude PID 89280):
Claude 89280 yunasun 37u CHR 15,291 0t0 605 /dev/ptmx
Claude 89280 yunasun 106u CHR 15,387 0t0 605 /dev/ptmx
Claude 89280 yunasun 114u CHR 15,383 0t0 605 /dev/ptmx
... (502 more identical lines)
`sysctl kern.tty.ptmx_max` → 511 (system limit)
Steps to Reproduce
- Open the Claude desktop app
- Start a conversation and run many Bash tool calls (e.g. run dozens of shell commands over an extended session)
- Check PTY usage:
lsof /dev/ptmx | awk '{print $1}' | sort | uniq -c - Observe Claude accumulating hundreds of
/dev/ptmxfile descriptors - Once count reaches ~508+, try to open a new macOS Terminal.app window
- Terminal shows
[forkpty: Device not configured]and fails to open
Workaround: Quit and restart the Claude desktop app — all leaked PTYs are released immediately.
Claude Model
None
Is this a regression?
Yes, this worked in a previous version
Last Working Version
2.1.185 (Claude Code)
Claude Code Version
Claude 1.14271.0 (c8f4d8) 2026-06-18T05:47:57.000Z
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
- System: macOS Darwin 25.3.0
- Reproduced after one long session with many Bash tool calls
- The PTY count grows monotonically — never drops between tool calls
- Restarting Claude fully resolves the issue until PTYs accumulate again
- Other apps (Electron/VSCode) only hold 2 PTY handles under the same usage
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗