test_fork_modified.rb

Yann Rouillard, 03/09/2014 01:13 PM

Download (267 Bytes)

 
1
  a = []
2
  trap(:INT) { a.push(1) }
3
  trap(:TERM) { a.push(2) }
4
  pid = $$
5
  begin
6
    fork do
7
      sleep 0.5
8
      Process.kill(:INT, pid)
9
      sleep 0.5
10
      Process.kill(:TERM, pid)
11
    end
12

    
13
    sleep 1
14
    a.sort
15
  rescue NotImplementedError
16
    [1, 2]
17
  end
18