diff --git a/lib/debug/session.rb b/lib/debug/session.rb index 4e029fcbd..e9d95775c 100644 --- a/lib/debug/session.rb +++ b/lib/debug/session.rb @@ -2524,6 +2524,16 @@ def daemon(*args) module TrapInterceptor def trap sig, *command, &command_proc + sym = + case sig + when String + sig.to_sym + when Integer + Signal.signame(sig)&.to_sym + else + sig + end + case sig&.to_s&.to_sym when :INT, :SIGINT if defined?(SESSION) && SESSION.active? && SESSION.intercept_trap_sigint? diff --git a/test/console/trap_test.rb b/test/console/trap_test.rb index 4664d3757..17c4ccfa7 100644 --- a/test/console/trap_test.rb +++ b/test/console/trap_test.rb @@ -24,6 +24,32 @@ def test_sigint type 'c' end end + + def test_trap_with + debug_code %q{ + 1| trap(:INT){} # Symbol + 2| _ = 1 + }, remote: false do + type 'n' + type 'n' + end + + debug_code %q{ + 1| trap('INT'){} # String + 2| _ = 1 + }, remote: false do + type 'n' + type 'n' + end + + debug_code %q{ + 1| trap(Signal.list['INT']){} if Signal.list['INT'] # Integer + 2| _ = 1 + }, remote: false do + type 'n' + type 'n' + end + end end end