Skip to content

fix: propagate read errors from getKeyPress instead of busy-looping - #16

Open
ruslsalimov wants to merge 2 commits into
atomicgo:mainfrom
ruslsalimov:fix/propagate-read-errors
Open

ruslsalimov wants to merge 2 commits into
atomicgo:mainfrom
ruslsalimov:fix/propagate-read-errors

Conversation

@ruslsalimov

Copy link
Copy Markdown

Fixes #15

getKeyPress turned every error from inputTTY.Read into an empty keys.Key{} with a nil error.
When the terminal goes away (window closed, SIGHUP not delivered or ignored), read on /dev/tty
returns EIO immediately and forever, so Listen spins at 100%+ CPU and never returns.
Measurements, debugger output and the commit history behind the swallowing are in the issue.

Changes

  • getKeyPress returns the read error, as the original 2022-06-01 code did.
  • Listen decides what a read error means: if stopRoutine is already set — stop() sets it
    before closing/cancelling the fd — the read was interrupted by our own stop (Close on Unix,
    CancelIoEx on Windows) and it is a normal shutdown; otherwise Listen restores the console
    (stop() + stopListener()) and returns the error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

getKeyPress swallows every read error → Listen busy-loops at 100%+ CPU after the terminal is gone

1 participant