Claude Code leaks pty handles — exhausts pseudo-terminals on macOS after long session

Resolved 💬 2 comments Opened May 28, 2026 by Blakefolgado Closed Jun 23, 2026

Summary

After a long Claude Code session with many Bash tool calls, the Claude process accumulates hundreds of open pseudo-terminal (pty) handles without releasing them. This eventually exhausts the macOS pty pool, causing all new terminal windows/tabs to fail with:

[forkpty: Device not configured]
[Could not create a new process and open a pseudo-tty.]

Reproduction

Run a long Claude Code session with many Bash tool calls, then:

lsof | grep ptmx | awk '{print $1}' | sort | uniq -c | sort -rn | head -10

Output showed 511 pty handles held by the Claude process — enough to prevent any new terminal from opening.

Environment

  • macOS 26.5 (Build 25F71, Darwin 25.5.0)
  • Claude Code desktop app

Expected behaviour

Pty handles should be released after each Bash tool call completes.

Actual behaviour

Handles accumulate across the session until the pty pool is exhausted.

Workaround

Quit and relaunch Claude Code — this releases all handles.

View original on GitHub ↗

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