diff options
author | aycabta <aycabta@gmail.com> | 2021-09-07 01:57:00 +0900 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2021-09-07 01:59:13 +0900 |
commit | 4885a61b124967afc06a38d317225d02270d9dce (patch) | |
tree | afcfbf5065ab6ee09bd94b21a17d0e3149c46b6e /lib/reline | |
parent | e8ad881336974d1719359d7545b6b9a0efe0dc79 (diff) |
[ruby/reline] Rescue ArgumentError from Signal.trap(:TSTP) on Windows
https://github.com/ruby/reline/commit/8da8182d1c
Diffstat (limited to 'lib/reline')
-rw-r--r-- | lib/reline/line_editor.rb | 16 |
1 files 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? |