What happened?
PTY leak when enableInteractiveShell=true causes system-wide PTY exhaustion on macOS
Environment
- Gemini CLI: 0.44.x
- Node.js: 24.x
- macOS: (please fill in exact version)
- Running mode:
gemini -r
- MCP enabled (Context7 MCP)
enableInteractiveShell=true
Summary
After running Gemini CLI for an extended period with interactive shell enabled, the process appears to leak PTY-related resources.
Eventually the entire macOS user session becomes unable to allocate new pseudo-terminals.
At that point, not only Gemini fails, but all PTY consumers fail system-wide.
Symptoms
Gemini starts failing with:
forkpty: Device not configured
posix_openpt failed: Device not configured
Then unrelated tools also fail:
returns:
script: openpty: Device not configured
Python:
import pty
pty.spawn('/bin/bash')
returns:
OSError: out of pty devices
Even sudo becomes unusable:
returns:
sudo: unable to allocate pty: Device not configured
Diagnostics
Active TTY usage appears low:
lsof | grep /dev/ttys | wc -l
Output:
System tty devices:
Output:
Gemini process:
lsof -p <gemini_pid> | wc -l
Output:
Gemini is holding both the current terminal and an internal PTY:
/dev/ttys009
/dev/ttys238
Observed child processes:
bash
bash
tail -f /dev/null
Reproduction
- Enable interactive shell
- Run Gemini in long-lived mode:
-
Use the agent for an extended period
-
Eventually PTY allocation starts failing
-
Failure propagates to:
- Gemini
- script
- python pty.spawn()
- sudo
Workaround
Disable interactive shell:
{
"tools": {
"shell": {
"enableInteractiveShell": false
}
}
}
After disabling interactive shell and restarting the user session, the problem disappears.
Expected behavior
Interactive shell sessions should fully release PTY resources after command completion and should not cause system-wide PTY exhaustion.
Additional notes
This may be related to the recent node-pty issues reported in 0.44.x. The issue becomes significantly more visible when running:
gemini -r
- MCP servers enabled
- long-lived agent sessions
- Node.js 24.x
What did you expect to happen?
no error, no run out of the resources.
Client information
Client Information
Run gemini to enter the interactive CLI, then run the /about command.
> /about
# paste output here
Login information
No response
Anything else we need to know?
No response
What happened?
PTY leak when
enableInteractiveShell=truecauses system-wide PTY exhaustion on macOSEnvironment
gemini -renableInteractiveShell=trueSummary
After running Gemini CLI for an extended period with interactive shell enabled, the process appears to leak PTY-related resources.
Eventually the entire macOS user session becomes unable to allocate new pseudo-terminals.
At that point, not only Gemini fails, but all PTY consumers fail system-wide.
Symptoms
Gemini starts failing with:
Then unrelated tools also fail:
returns:
Python:
returns:
Even sudo becomes unusable:
returns:
Diagnostics
Active TTY usage appears low:
Output:
System tty devices:
Output:
Gemini process:
Output:
Gemini is holding both the current terminal and an internal PTY:
Observed child processes:
Reproduction
Use the agent for an extended period
Eventually PTY allocation starts failing
Failure propagates to:
Workaround
Disable interactive shell:
{ "tools": { "shell": { "enableInteractiveShell": false } } }After disabling interactive shell and restarting the user session, the problem disappears.
Expected behavior
Interactive shell sessions should fully release PTY resources after command completion and should not cause system-wide PTY exhaustion.
Additional notes
This may be related to the recent node-pty issues reported in 0.44.x. The issue becomes significantly more visible when running:
gemini -rWhat did you expect to happen?
no error, no run out of the resources.
Client information
Client Information
Run
geminito enter the interactive CLI, then run the/aboutcommand.Login information
No response
Anything else we need to know?
No response