summaryrefslogtreecommitdiff
path: root/test/ruby/test_signal.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/ruby/test_signal.rb')
-rw-r--r--test/ruby/test_signal.rb7
1 files changed, 5 insertions, 2 deletions
diff --git a/test/ruby/test_signal.rb b/test/ruby/test_signal.rb
index 61240cd65d..77c97be98c 100644
--- a/test/ruby/test_signal.rb
+++ b/test/ruby/test_signal.rb
@@ -4,9 +4,10 @@ $KCODE = 'none'
class TestSignal < Test::Unit::TestCase
def test_signal
- if defined? Process.kill
+ defined?(Process.kill) or return
+ begin
$x = 0
- trap "SIGINT", proc{|sig| $x = 2}
+ oldtrap = trap "SIGINT", proc{|sig| $x = 2}
Process.kill "SIGINT", $$
sleep 0.1
assert_equal(2, $x)
@@ -19,6 +20,8 @@ class TestSignal < Test::Unit::TestCase
end
assert(x)
assert_match(/Interrupt/, x.message)
+ ensure
+ trap "SIGINT", oldtrap
end
end
end