From 4885a61b124967afc06a38d317225d02270d9dce Mon Sep 17 00:00:00 2001 From: aycabta Date: Tue, 7 Sep 2021 01:57:00 +0900 Subject: [PATCH] [ruby/reline] Rescue ArgumentError from Signal.trap(:TSTP) on Windows https://github.com/ruby/reline/commit/8da8182d1c --- lib/reline/line_editor.rb | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb index a2ad758081..33bcba44f1 100644 --- a/lib/reline/line_editor.rb +++ b/lib/reline/line_editor.rb @@ -170,10 +170,13 @@ class Reline::LineEditor @old_trap.call end } - @old_tstp_trap = Signal.trap(:TSTP) { - Reline::IOGate.ungetc("\C-z".ord) - @old_tstp_trap.call if @old_tstp_trap.respond_to?(:call) - } + begin + @old_tstp_trap = Signal.trap(:TSTP) { + Reline::IOGate.ungetc("\C-z".ord) + @old_tstp_trap.call if @old_tstp_trap.respond_to?(:call) + } + rescue ArgumentError + end Reline::IOGate.set_winch_handler do @rest_height = (Reline::IOGate.get_screen_size.first - 1) - Reline::IOGate.cursor_pos.y old_screen_size = @screen_size @@ -215,7 +218,10 @@ class Reline::LineEditor def finalize Signal.trap('SIGINT', @old_trap) - Signal.trap('SIGTSTP', @old_tstp_trap) + begin + Signal.trap('SIGTSTP', @old_tstp_trap) + rescue ArgumentError + end end def eof?