Skip to content

Commit e51eaa6

Browse files
committed
Check Errno::EIO
Catch Errno::EIO what will be occurred if the console terminates I/O before Reline finishes rendering.
1 parent 0ea2cc9 commit e51eaa6

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

bin/multiline_repl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,8 @@ rescue Interrupt
3737
ensure
3838
`stty #{stty_save}` if stty_save
3939
end
40-
puts
40+
begin
41+
puts
42+
rescue Errno::EIO
43+
# Maybe the I/O has been closed.
44+
end

lib/reline.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,8 @@ def readline(prompt = '', add_hist = false)
243243
break if line_editor.finished?
244244
end
245245
Reline::IOGate.move_cursor_column(0)
246+
rescue Errno::EIO
247+
# Maybe the I/O has been closed.
246248
rescue StandardError => e
247249
line_editor.finalize
248250
Reline::IOGate.deprep(otio)

lib/reline/ansi.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ def self.getc
6767
end
6868
c = @@input.raw(intr: true, &:getbyte)
6969
(c == 0x16 && @@input.raw(min: 0, tim: 0, &:getbyte)) || c
70+
rescue Errno::EIO
71+
# Maybe the I/O has been closed.
72+
nil
7073
end
7174

7275
def self.ungetc(c)

0 commit comments

Comments
 (0)