Repository navigation
Catches Errno::ENODEV and Errno::EBADF in get_screen_size. Closes #690 - #702
Merged
Merged
Conversation
Member
|
Additional information how to reproduce these Errno Errno::ENOTTYecho | ruby -rio/console -e "STDIN.winsize"Errno::ENODEVruby -rio/console -e "STDIN.winsize" < /dev/nullErrno::EBADFruby -rio/console -e "io=IO.popen('cat','r+'); fd=io.inspect[/\d+/].to_i; io2=IO.for_fd(fd); io.close; io2.winsize"(Haven't found a way to raise EBADF from |
tompng
reviewed
May 10, 2024
| return s if s[0] > 0 && s[1] > 0 | ||
| [24, 80] | ||
| rescue Errno::ENOTTY | ||
| rescue Errno::ENOTTY, Errno::ENODEV, Errno::EBADF |
Member
There was a problem hiding this comment.
I think adding Errno::ENODEV is enough.
The main problem of #690 is that just requiring 'reline' was calling IO#winsize. #703 will fix it.
We need to rescue Errno::ENOTTY and Errno::ENODEV to make reline work in these two scenario.
# For Errno::ENODEV
ruby -rreline -e "Reline.readline" < /dev/null
# For Errno::ENOTTY
ruby -rreline -e "Reline.readline" < file
But for Errno::EBADF, I think we don't need to rescue it. Just like we don't rescue IOError here.
STDIN.close
STDIN.winsize #=> closed stream (IOError)
Reline.readline #=> `tty?': closed stream (IOError)
Contributor
Author
There was a problem hiding this comment.
Ok, just catching Errno::ENOTTY and Errno::ENODEV
matzbot
pushed a commit
to ruby/ruby
that referenced
this pull request
May 22, 2024
get_screen_size. Closes ruby/reline#690 (ruby/reline#702) * Catches exceptions Errno::ENODEV and Errno::EBADF in get_screen_size. Closes ruby/reline#690 * Just catching Errno::ENOTTY and Errno::ENODEV ruby/reline@a5b5298e4a
Contributor
Author
Welcome. Thank you. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.