Skip to content

Commit

Permalink
[ruby/reline] Check Errno::EIO
Browse files Browse the repository at this point in the history
Catch Errno::EIO what will be occurred if the console terminates I/O before
Reline finishes rendering.

ruby/reline@e51eaa6d43
  • Loading branch information
aycabta committed Aug 18, 2020
1 parent f0d3d4f commit 215fe54
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/reline.rb
Expand Up @@ -243,6 +243,8 @@ def readline(prompt = '', add_hist = false)
break if line_editor.finished?
end
Reline::IOGate.move_cursor_column(0)
rescue Errno::EIO
# Maybe the I/O has been closed.
rescue StandardError => e
line_editor.finalize
Reline::IOGate.deprep(otio)
Expand Down
3 changes: 3 additions & 0 deletions lib/reline/ansi.rb
Expand Up @@ -67,6 +67,9 @@ def self.getc
end
c = @@input.raw(intr: true, &:getbyte)
(c == 0x16 && @@input.raw(min: 0, tim: 0, &:getbyte)) || c
rescue Errno::EIO
# Maybe the I/O has been closed.
nil
end

def self.ungetc(c)
Expand Down

0 comments on commit 215fe54

Please sign in to comment.