Skip to content

fix(cli): suppress OSError EIO during interrupt shutdown (Closes #13720)#13792

Closed
ms-alan wants to merge 1 commit into
NousResearch:mainfrom
ms-alan:fix/13720-suppress-eio
Closed

fix(cli): suppress OSError EIO during interrupt shutdown (Closes #13720)#13792
ms-alan wants to merge 1 commit into
NousResearch:mainfrom
ms-alan:fix/13720-suppress-eio

Conversation

@ms-alan

@ms-alan ms-alan commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

Summary

When the user interrupts a long-running task, prompt_toolkit flushes stdout. If stdout is in a broken state (pipe closed, terminal gone), this raises OSError with errno.EIO — which crashed the CLI.

Root cause: The except (KeyError, OSError) block at cli.py:~10660 only handled "is not registered" and "Bad file descriptor" string checks. errno.EIO fell through to raise, crashing the CLI with OSError: [Errno 5] Input/output error.

Fix: Add getattr(_stdin_err, "errno", 0) == errno.EIO to the condition so EIO errors are silently suppressed instead of raised.

Changes

  • cli.py: Add errno import + EIO check in the except (KeyError, OSError) handler

Testing

Simulate: run a long task, interrupt with Ctrl+C while stdout is broken → no crash

Closes #13720

…Research#13720)

When a long-running task is interrupted, prompt_toolkit flushes stdout.
If stdout is in a broken state (pipe closed, /dev/null), this raises
OSError with errno.EIO. The existing except (KeyError, OSError) block
only handled 'is not registered' / 'Bad file descriptor' strings.

Add errno.EIO check so EIO errors are silently suppressed instead of
crashing the CLI. Import errno at top of cli.py.
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/cli CLI entry point, hermes_cli/, setup wizard labels Apr 22, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Likely duplicate of #13720 — same root cause (OSError EIO in CLI interrupt shutdown), same fix approach.

@trevorgordon981

Copy link
Copy Markdown

I have verified this solution by inspecting the code changes. The fix adds a check for (Input/Output error) to the existing exception handler during interrupt shutdown. This prevents spurious crashes or error messages when becomes unusable due to an error, which can occur with certain Python installations (e.g., -managed cPython on macOS) during interrupts. The CLI now handles this gracefully with a helpful message.\n\nTested and confirmed. ✅

@teknium1

Copy link
Copy Markdown
Contributor

Closing in favor of #15834 (salvaged from #13720). Your patch only covered the outer except (KeyError, OSError) block, but the crash actually lands inside the asyncio _suppress_closed_loop_errors handler — vt100's emergency flush fires through the event loop before the outer block ever sees it. #13720's fix covers both sites, which is why we went with it. Thanks for the report and for referencing the issue.

@teknium1 teknium1 closed this Apr 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants