[前][次][番号順一覧][スレッド一覧]

ruby-changes:65727

From: Koichi <ko1@a...>
Date: Fri, 2 Apr 2021 01:57:55 +0900 (JST)
Subject: [ruby-changes:65727] 1ac68bba4e (master): [ruby/irb] SIGINT should raise Interrupt after IRB session

https://git.ruby-lang.org/ruby.git/commit/?id=1ac68bba4e

From 1ac68bba4ef9e51c383ad9bad21d41a5ec8c0869 Mon Sep 17 00:00:00 2001
From: Koichi Sasada <ko1@a...>
Date: Thu, 1 Apr 2021 19:06:10 +0900
Subject: [ruby/irb] SIGINT should raise Interrupt after IRB session

https://github.com/ruby/irb/commit/5832cfe75b
---
 lib/irb.rb            | 3 ++-
 test/irb/test_init.rb | 6 ++++++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/lib/irb.rb b/lib/irb.rb
index 5a2aed0..93c4d25 100644
--- a/lib/irb.rb
+++ b/lib/irb.rb
@@ -472,7 +472,7 @@ module IRB https://github.com/ruby/ruby/blob/trunk/lib/irb.rb#L472
       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 https://github.com/ruby/ruby/blob/trunk/lib/irb.rb#L481
           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 83b4b5a..2c50b5d 100644
--- a/test/irb/test_init.rb
+++ b/test/irb/test_init.rb
@@ -64,6 +64,12 @@ module TestIRB https://github.com/ruby/ruby/blob/trunk/test/irb/test_init.rb#L64
       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)
-- 
cgit v1.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]