google-gemini / google-gemini/gemini-cli
[BUG] PTY Master Device Exhaustion (ENXIO) on macOS after prolonged usage in YOLO mode
- Dominant language
- TypeScript
- Stars
- 107k
- Forks
- 14.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 45
Description
### Description
After running `gemini-cli` (v0.38.1) for an extended period (weeks) with `--approval-mode yolo`, the system eventually hits the macOS PTY limit (`kern.tty.ptmx_max = 511`), preventing any new terminal sessions from opening system-wide with the error: `Device not configured`.
### Diagnostic Evidence
- **System Limit:** `sysctl kern.tty.ptmx_max` → 511
- **Current Usage:** `lsof | grep "/dev/ptmx" | wc -l` → 511
- **Top Consumer:** PID 11595 (`node .../bin/gemini --approval-mode yolo`) is holding **230** PTY master descriptors. Other orphaned Gemini instances are holding the remainder.
- **Process State:** `sample` of the process shows it is healthy and sitting in a `uv__io_poll` wait state, but it has failed to release `/dev/ptmx` descriptors for sub-agents or tool calls (e.g., `ck`).
- **Uptime:** The leaking processes have uptimes ranging from 1 to 17 days.
### Steps to Reproduce
1. Run Gemini CLI in a persistent session (e.g., within `tmux`).
2. Use `--approval-mode yolo`.
3. Perform numerous tasks that invoke sub-agents or external search tools over several days.
4. Observe the PTY count increasing via `lsof` without ever decreasing.
### Environment
- **OS:** macOS 15.7.2 (ARM64)
- **Node Version:** 22.21.1
- **Gemini CLI Version:** 0.38.1
### Related Issues
Likely related to #22814 (File descriptor leak in ShellExecutionService) and #22001 (Terminal Instance Resource Retention).
Contributor guide
Assessment
This issue has not been assessed yet.