gemini-cli - 💡(How to fix) Fix ioctl(2) failed, EBADF during PTY resize on sub-agent termination (Race Condition)

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

Since the update to 0.43.0, which introduced isolated sub-agents and faster lifecycle management, gemini-cli occasionally crashes with an EBADF error in node-pty. This happens due to a race condition where the UI (Ink/React) attempts to resize a pseudo-terminal (PTY) just as the sub-agent completes its task and the file descriptor is closed by the OS. Same error persists in 0.44.0 (preview) also... ERROR ioctl(2) failed, EBADF The resizePty method in _ShellExecutionService should try/catch EBADF errors (or check if the fd is still valid/alive) and fail gracefully instead of throwing an unhandled exception that crashes the entire CLI session. Same error persists in 0.44.0 (preview) also...

RAW_BUFFERClick to expand / collapse

What happened?

Since the update to 0.43.0, which introduced isolated sub-agents and faster lifecycle management, gemini-cli occasionally crashes with an EBADF error in node-pty. This happens due to a race condition where the UI (Ink/React) attempts to resize a pseudo-terminal (PTY) just as the sub-agent completes its task and the file descriptor is closed by the OS. Same error persists in 0.44.0 (preview) also...

Stack Trace: ERROR ioctl(2) failed, EBADF

  • UnixTerminal.resize (@lydell/node-pty/unixTerminal.js:243:13)
  • _ShellExecutionService.resizePty (chunk-U6X4OPT5.js:286186:30)

What did you expect to happen?

Expected behavior: The resizePty method in _ShellExecutionService should try/catch EBADF errors (or check if the fd is still valid/alive) and fail gracefully instead of throwing an unhandled exception that crashes the entire CLI session.

Client information

  • CLI Version: 0.43.0
  • Git Commit: c0775c38b
  • Session ID: cf31fdec-f855-4d81-a3fb-e7f50293fceb (it didn´t happen in this session... this session is the session in which I am trying to debunk what had happen in the previous session...
  • Operating System: linux (Linux Mint 21.3) v24.14.0
  • Sandbox Environment: no sandbox
  • Model Version: auto-gemini-3
  • Auth Type: oauth-personal
  • Memory Usage: 395.7 MB
  • Terminal Name: Unknown
  • Terminal Background: #000000
  • Kitty Keyboard Protocol: Unsupported

Login information

Google Account

Anything else we need to know?

Session ID: cf31fdec-f855-4d81-a3fb-e7f50293fceb (it didn´t happen in this session... this session is the session in which I am trying to debunk what had happen in the previous session...

Same error persists in 0.44.0 (preview) also...

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING