Skip to content

Commit 3cf0253

Browse files
Rubyko1
Ruby
authored andcommitted
work correctly with trap(Integer,...)
follow up for #976
1 parent f4b4dda commit 3cf0253

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

lib/debug/session.rb

+10
Original file line numberDiff line numberDiff line change
@@ -2524,6 +2524,16 @@ def daemon(*args)
25242524

25252525
module TrapInterceptor
25262526
def trap sig, *command, &command_proc
2527+
sym =
2528+
case sig
2529+
when String
2530+
sig.to_sym
2531+
when Integer
2532+
Signal.signame(sig)&.to_sym
2533+
else
2534+
sig
2535+
end
2536+
25272537
case sig&.to_s&.to_sym
25282538
when :INT, :SIGINT
25292539
if defined?(SESSION) && SESSION.active? && SESSION.intercept_trap_sigint?

test/console/trap_test.rb

+26
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,32 @@ def test_sigint
2424
type 'c'
2525
end
2626
end
27+
28+
def test_trap_with
29+
debug_code %q{
30+
1| trap(:INT){} # Symbol
31+
2| _ = 1
32+
}, remote: false do
33+
type 'n'
34+
type 'n'
35+
end
36+
37+
debug_code %q{
38+
1| trap('INT'){} # String
39+
2| _ = 1
40+
}, remote: false do
41+
type 'n'
42+
type 'n'
43+
end
44+
45+
debug_code %q{
46+
1| trap(Signal.list['INT']){} if Signal.list['INT'] # Integer
47+
2| _ = 1
48+
}, remote: false do
49+
type 'n'
50+
type 'n'
51+
end
52+
end
2753
end
2854
end
2955

0 commit comments

Comments
 (0)