gemini-cli - 💡(How to fix) Fix Critical Crash: ioctl(2) failed, EBADF in ShellExecutionService.resizePty

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

The CLI crashes with a Bad File Descriptor error when a PTY resize is triggered at the exact moment a process Error Trace: 1 Error: ioctl(2) failed, EBADF The ShellExecutionService.resizePty method (found in chunk-BE42OOYM.js) includes error handling for ESRCH and its file descriptor is closed before the resize call completes, EBADF is thrown, causing an unhandled exception

Root Cause

Root Cause Analysis: The ShellExecutionService.resizePty method (found in chunk-BE42OOYM.js) includes error handling for ESRCH and Windows-specific exit errors, but it does not catch EBADF. When the underlying node-pty instance is destroyed or its file descriptor is closed before the resize call completes, EBADF is thrown, causing an unhandled exception that terminates the CLI.

RAW_BUFFERClick to expand / collapse

What happened?

Description: The CLI crashes with a Bad File Descriptor error when a PTY resize is triggered at the exact moment a process terminates. This appears to be a race condition where the UI attempts to resize a terminal process that has already closed its file descriptor.

Error Trace:

1 Error: ioctl(2) failed, EBADF 2 at UnixTerminal.resize (node-pty/unixTerminal.js:243:13) 3 at _ShellExecutionService.resizePty (chunk-BE42OOYM.js:320262:30) 4 at interactiveCli-RDMZS6KL.js:6529:31 (React useEffect)

Root Cause Analysis: The ShellExecutionService.resizePty method (found in chunk-BE42OOYM.js) includes error handling for ESRCH and Windows-specific exit errors, but it does not catch EBADF. When the underlying node-pty instance is destroyed or its file descriptor is closed before the resize call completes, EBADF is thrown, causing an unhandled exception that terminates the CLI.

What did you expect to happen?

Suggested Fix: Update the try/catch block in ShellExecutionService.resizePty to also ignore errors where the message includes "EBADF" or the code is EBADF, as this is a terminal state for the process anyway.

Client information

  • CLI Version: 0.44.0
  • Git Commit: 1000b33d4
  • Session ID: 198b1255-18fd-4f7c-a5d7-02eea9703a6d
  • Operating System: linux v20.20.2
  • Sandbox Environment: no sandbox
  • Model Version: gemini-3-flash-preview
  • Auth Type: oauth-personal
  • Memory Usage: 757.5 MB
  • Terminal Name: Unknown
  • Terminal Background: Unknown
  • Kitty Keyboard Protocol: Unsupported

Login information

No response

Anything else we need to know?

No response

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