blob: 6e0c49a75e80fb84b18c2aaca494bc6132f7190b (
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
require 'em_test_helper'
if EM.kqueue?
class TestProcessWatch < Test::Unit::TestCase
module ParentProcessWatcher
def process_forked
$forked = true
end
end
module ChildProcessWatcher
def process_exited
$exited = true
end
def unbind
$unbind = true
EM.stop
end
end
def setup
EM.kqueue = true
end
def teardown
EM.kqueue = false
end
def test_events
omit_if(rbx?)
omit_if(jruby?)
EM.run{
# watch ourselves for a fork notification
EM.watch_process(Process.pid, ParentProcessWatcher)
$fork_pid = fork{ sleep }
child = EM.watch_process($fork_pid, ChildProcessWatcher)
$pid = child.pid
EM.add_timer(0.2){
Process.kill('TERM', $fork_pid)
}
}
assert_equal($pid, $fork_pid)
assert($forked)
assert($exited)
assert($unbind)
end
end
end
|