summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKoichi Sasada <[email protected]>2021-04-01 19:06:10 +0900
committergit <[email protected]>2021-04-02 01:57:44 +0900
commit1ac68bba4ef9e51c383ad9bad21d41a5ec8c0869 (patch)
treefe46c5c7a46fed1f9ff71488c6e1495dfcf16501
parent8e636bd0de7ccb7cfd17cc3b9b79f3bd05a857fd (diff)
[ruby/irb] SIGINT should raise Interrupt after IRB session
https://github.com/ruby/irb/commit/5832cfe75b
-rw-r--r--lib/irb.rb3
-rw-r--r--test/irb/test_init.rb6
2 files changed, 8 insertions, 1 deletions
diff --git a/lib/irb.rb b/lib/irb.rb
index 5a2aed0353..93c4d25c92 100644
--- a/lib/irb.rb
+++ b/lib/irb.rb
@@ -472,7 +472,7 @@ module IRB
conf[:IRB_RC].call(context) if conf[:IRB_RC]
conf[:MAIN_CONTEXT] = context
- trap("SIGINT") do
+ prev_trap = trap("SIGINT") do
signal_handle
end
@@ -481,6 +481,7 @@ module IRB
eval_input
end
ensure
+ trap("SIGINT", prev_trap)
conf[:AT_EXIT].each{|hook| hook.call}
end
end
diff --git a/test/irb/test_init.rb b/test/irb/test_init.rb
index 83b4b5a543..2c50b5da3a 100644
--- a/test/irb/test_init.rb
+++ b/test/irb/test_init.rb
@@ -64,6 +64,12 @@ module TestIRB
ENV["IRBRC"] = backup_irbrc
end
+ def test_recovery_sigint
+ bundle_exec = ENV.key?('BUNDLE_GEMFILE') ? ['-rbundler/setup'] : []
+ status = assert_in_out_err(bundle_exec + %w[-W0 -rirb -e binding.irb;loop{Process.kill("SIGINT",$$)} -- -f --], "exit\n", //, //)
+ Process.kill("SIGKILL", status.pid) if !status.exited? && !status.stopped? && !status.signaled?
+ end
+
private
def with_argv(argv)