Project

General

Profile

Bug #4579 » test_fork_random.rb

normalperson (Eric Wong), 04/15/2011 11:46 AM

 
require "openssl"
require "securerandom"

SecureRandom.random_bytes(4)
pid = fork do
p [ $$, SecureRandom.random_bytes(4) ]
end
Process.waitpid2(pid)

loop do
xpid = fork do
p [ $$, SecureRandom.random_bytes(4) ] if $$ == pid
end
Process.waitpid2(xpid)
break if xpid == pid
end
(1-1/6)