diff options
author | Samuel Williams <samuel.williams@oriontransfer.co.nz> | 2021-06-23 19:44:46 +1200 |
---|---|---|
committer | aycabta <aycabta@gmail.com> | 2021-06-25 17:42:45 +0900 |
commit | e788481843d71030bd5dfee28fd0fc22dcae2f97 (patch) | |
tree | e8b01fc6514c1afc47231897384b707c2b645305 | |
parent | d340b091a82461b039cdfb9ba9c7ffee0ec89f0a (diff) |
[ruby/reline] Avoid using blocking `IO.select`.
https://github.com/ruby/reline/commit/de94746393
-rw-r--r-- | lib/reline/ansi.rb | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/lib/reline/ansi.rb b/lib/reline/ansi.rb index bbb0623b16..c7c74ccb90 100644 --- a/lib/reline/ansi.rb +++ b/lib/reline/ansi.rb @@ -183,12 +183,7 @@ class Reline::ANSI unless @@buf.empty? return false end - rs, = IO.select([@@input], [], [], 0.00001) - if rs and rs[0] - false - else - true - end + !@@input.wait_readable(0) end def self.ungetc(c) @@ -197,8 +192,7 @@ class Reline::ANSI def self.retrieve_keybuffer begin - result = select([@@input], [], [], 0.001) - return if result.nil? + return unless @@input.wait_readable(0.001) str = @@input.read_nonblock(1024) str.bytes.each do |c| @@buf.push(c) |