2007-12-21 03:38:16 -05:00
|
|
|
assert_equal '0', %q{
|
2007-12-21 16:35:08 -05:00
|
|
|
begin
|
|
|
|
GC.stress = true
|
|
|
|
pid = fork {}
|
|
|
|
Process.wait pid
|
|
|
|
$?.to_i
|
|
|
|
rescue NotImplementedError
|
|
|
|
0
|
|
|
|
end
|
2007-12-21 03:38:16 -05:00
|
|
|
}, '[ruby-dev:32404]'
|
2009-02-17 20:49:17 -05:00
|
|
|
|
|
|
|
assert_finish 10, %q{
|
2009-02-26 00:02:21 -05: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-17 20:49:17 -05:00
|
|
|
end
|
|
|
|
}, '[ruby-core:22158]'
|
2009-06-07 19:59:58 -04:00
|
|
|
|
2018-01-09 03:05:40 -05:00
|
|
|
# temporarily stop this test to enable explicit failure when
|
|
|
|
# timer thread couldn't be created (r61706 and r61717).
|
|
|
|
assert_normal_exit(<<'End', '[ruby-dev:37934]') if false
|
2014-06-07 15:57:46 -04:00
|
|
|
main = Thread.current
|
|
|
|
Thread.new { sleep 0.01 until main.stop?; Thread.kill main }
|
2015-11-10 03:50:06 -05:00
|
|
|
Process.setrlimit(:NPROC, 1) if defined?(Process::RLIMIT_NPROC)
|
2009-06-07 19:59:58 -04:00
|
|
|
fork {}
|
|
|
|
End
|
2010-04-19 12:03:39 -04:00
|
|
|
|
|
|
|
assert_equal 'ok', %q{
|
|
|
|
begin
|
2014-06-07 15:57:46 -04:00
|
|
|
r, w = IO.pipe
|
2010-04-19 12:03:39 -04:00
|
|
|
if pid1 = fork
|
2014-06-07 15:57:46 -04:00
|
|
|
w.close
|
|
|
|
r.read(1)
|
2010-04-19 12:03:39 -04:00
|
|
|
Process.kill("USR1", pid1)
|
|
|
|
_, s = Process.wait2(pid1)
|
|
|
|
s.success? ? :ok : :ng
|
|
|
|
else
|
2014-06-07 15:57:46 -04:00
|
|
|
r.close
|
2010-04-19 12:03:39 -04:00
|
|
|
if pid2 = fork
|
2014-06-07 15:57:46 -04:00
|
|
|
trap("USR1") { Time.now.to_s; Process.kill("USR2", pid2) }
|
|
|
|
w.close
|
2010-04-19 12:03:39 -04:00
|
|
|
Process.wait2(pid2)
|
|
|
|
else
|
2014-06-07 15:57:46 -04:00
|
|
|
w.close
|
|
|
|
sleep 0.2
|
2010-04-19 12:03:39 -04:00
|
|
|
end
|
2014-06-07 15:57:46 -04:00
|
|
|
exit true
|
2010-04-19 12:03:39 -04:00
|
|
|
end
|
|
|
|
rescue NotImplementedError
|
|
|
|
:ok
|
|
|
|
end
|
|
|
|
}, '[ruby-core:28924]'
|
2011-06-30 18:29:34 -04:00
|
|
|
|
|
|
|
assert_equal '[1, 2]', %q{
|
|
|
|
a = []
|
2014-06-07 15:57:46 -04:00
|
|
|
main = Thread.current
|
|
|
|
trap(:INT) { a.push(1).size == 2 and main.wakeup }
|
|
|
|
trap(:TERM) { a.push(2).size == 2 and main.wakeup }
|
2011-06-30 18:29:34 -04:00
|
|
|
pid = $$
|
|
|
|
begin
|
2014-06-07 15:57:46 -04:00
|
|
|
pid = fork do
|
2011-06-30 18:29:34 -04:00
|
|
|
Process.kill(:INT, pid)
|
|
|
|
Process.kill(:TERM, pid)
|
|
|
|
end
|
2014-06-07 15:57:46 -04:00
|
|
|
Process.wait(pid)
|
2014-06-28 14:12:47 -04:00
|
|
|
100.times {break if a.size > 1; sleep 0.001}
|
2011-06-30 18:29:34 -04:00
|
|
|
a.sort
|
|
|
|
rescue NotImplementedError
|
|
|
|
[1, 2]
|
|
|
|
end
|
|
|
|
}, '[ruby-dev:44005] [Ruby 1.9 - Bug #4950]'
|
|
|
|
|