summaryrefslogtreecommitdiff
path: root/bootstraptest/test_fork.rb
blob: 60a74e8a2277c940c40fa1aebeea026cec3d13c3 (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
assert_equal '0', %q{
  begin
    GC.stress = true
    pid = fork {}
    Process.wait pid
    $?.to_i
  rescue NotImplementedError
    0
  end
}, '[ruby-dev:32404]'

assert_finish 10, %q{
  begin
    children = (1..10).map{
      Thread.start{fork{}}.value
    }
    while !children.empty? and pid = Process.wait
      children.delete(pid)
    end
  rescue NotImplementedError
  end
}, '[ruby-core:22158]'

assert_normal_exit(<<'End', '[ruby-dev:37934]')
  Thread.new { sleep 1; Thread.kill Thread.main }
  Process.setrlimit(:NPROC, 1)
  fork {}
End