summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authoraycabta <aycabta@gmail.com>2021-08-01 17:41:55 +0900
committeraycabta <aycabta@gmail.com>2021-08-04 18:29:42 +0900
commitde93b8b0697ab9554557f21d7a52a3172c5af5c3 (patch)
treea596a63d1c99a645dd4e3877772e53a271194e70 /lib
parent5bb7b571299a06f051b065dec9dd5194e82bd796 (diff)
Handle SIGINT in other thread correctly
Co-authored-by: Koichi Sasada <ko1@atdot.net>
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/4704
Diffstat (limited to 'lib')
-rw-r--r--lib/reline/line_editor.rb12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb
index 6257331886..97f12116b9 100644
--- a/lib/reline/line_editor.rb
+++ b/lib/reline/line_editor.rb
@@ -158,8 +158,16 @@ class Reline::LineEditor
end
Reline::IOGate.move_cursor_column(0)
scroll_down(1)
- @old_trap.call if @old_trap.respond_to?(:call) # can also be string, ex: "DEFAULT"
- raise Interrupt
+ case @old_trap
+ when 'DEFAULT', 'SYSTEM_DEFAULT'
+ raise Interrupt
+ when 'IGNORE'
+ # Do nothing
+ when 'EXIT'
+ exit
+ else
+ @old_trap.call
+ end
}
Reline::IOGate.set_winch_handler do
@rest_height = (Reline::IOGate.get_screen_size.first - 1) - Reline::IOGate.cursor_pos.y