1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
This commit is contained in:
Benoit Daloze 2021-03-27 13:02:41 +01:00
parent 44736a6b7a
commit 95d9fe9538
26 changed files with 501 additions and 84 deletions

View file

@ -29,7 +29,23 @@ describe "rescuing Interrupt" do
sleep
rescue Interrupt => e
e.signo.should == Signal.list["INT"]
e.signm.should == ""
["", "Interrupt"].should.include?(e.message)
end
end
end
describe "Interrupt" do
# This spec is basically the same as above,
# but it does not rely on Signal.trap(:INT, :SIG_DFL) which can be tricky
it "is raised on the main Thread by the default SIGINT handler" do
out = ruby_exe(<<-'RUBY', args: "2>&1")
begin
Process.kill :INT, Process.pid
sleep
rescue Interrupt => e
puts "Interrupt: #{e.signo}"
end
RUBY
out.should == "Interrupt: #{Signal.list["INT"]}\n"
end
end