summaryrefslogtreecommitdiff
path: root/test/ruby/test_signal.rb
blob: d9376b47ea535faba1a189dfe1aee8fa7cdc8b18 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
require 'test/unit'

$KCODE = 'none'

class TestSignal < Test::Unit::TestCase
  def test_signal
    if defined? Process.kill
      $x = 0
      trap "SIGINT", proc{|sig| $x = 2}
      Process.kill "SIGINT", $$
      sleep 0.1
      assert($x == 2)
    
      trap "SIGINT", proc{raise "Interrupt"}
    
      x = false
      begin
        Process.kill "SIGINT", $$
        sleep 0.1
      rescue
        x = $!
      end
      assert(x && /Interrupt/ =~ x.message)
    end
  end
end