2007-12-21 11:38:16 +03:00
|
|
|
assert_equal '0', %q{
|
2007-12-22 00:35:08 +03:00
|
|
|
begin
|
|
|
|
GC.stress = true
|
|
|
|
pid = fork {}
|
|
|
|
Process.wait pid
|
|
|
|
$?.to_i
|
|
|
|
rescue NotImplementedError
|
|
|
|
0
|
|
|
|
end
|
2007-12-21 11:38:16 +03:00
|
|
|
}, '[ruby-dev:32404]'
|
2009-02-18 04:49:17 +03:00
|
|
|
|
|
|
|
assert_finish 10, %q{
|
2009-02-26 08:02:21 +03:00
|
|
|
begin
|
|
|
|
children = (1..10).map{
|
|
|
|
Thread.start{fork{}}.value
|
|
|
|
}
|
|
|
|
while !children.empty? and pid = Process.wait
|
|
|
|
children.delete(pid)
|
|
|
|
end
|
|
|
|
rescue NotImplementedError
|
2009-02-18 04:49:17 +03:00
|
|
|
end
|
|
|
|
}, '[ruby-core:22158]'
|
2009-06-08 03:59:58 +04:00
|
|
|
|
|
|
|
assert_normal_exit(<<'End', '[ruby-dev:37934]')
|
|
|
|
Thread.new { sleep 1; Thread.kill Thread.main }
|
|
|
|
Process.setrlimit(:NPROC, 1)
|
|
|
|
fork {}
|
|
|
|
End
|
2010-04-19 20:03:39 +04:00
|
|
|
|
|
|
|
assert_equal 'ok', %q{
|
|
|
|
begin
|
|
|
|
if pid1 = fork
|
|
|
|
sleep 1
|
|
|
|
Process.kill("USR1", pid1)
|
|
|
|
_, s = Process.wait2(pid1)
|
|
|
|
s.success? ? :ok : :ng
|
|
|
|
else
|
|
|
|
if pid2 = fork
|
|
|
|
trap("USR1") { Time.now.to_s }
|
|
|
|
Process.wait2(pid2)
|
|
|
|
else
|
|
|
|
sleep 2
|
|
|
|
end
|
|
|
|
exit 0
|
|
|
|
end
|
|
|
|
rescue NotImplementedError
|
|
|
|
:ok
|
|
|
|
end
|
|
|
|
}, '[ruby-core:28924]'
|
2011-07-01 02:29:34 +04:00
|
|
|
|
|
|
|
assert_equal '[1, 2]', %q{
|
|
|
|
a = []
|
|
|
|
trap(:INT) { a.push(1) }
|
|
|
|
trap(:TERM) { a.push(2) }
|
|
|
|
pid = $$
|
|
|
|
begin
|
|
|
|
fork do
|
|
|
|
sleep 0.5
|
|
|
|
Process.kill(:INT, pid)
|
|
|
|
Process.kill(:TERM, pid)
|
|
|
|
end
|
|
|
|
|
|
|
|
sleep 1
|
|
|
|
a.sort
|
|
|
|
rescue NotImplementedError
|
|
|
|
[1, 2]
|
|
|
|
end
|
|
|
|
}, '[ruby-dev:44005] [Ruby 1.9 - Bug #4950]'
|
|
|
|
|