use Process.wait to wait for all child processes to finish before continuing.

child = fork do
  sleep 3
  puts 'Child says 'hi'!'
end

puts 'Waiting for the child process...'
Process.wait child
puts 'All done!'

赞 (0) 评论 分享 ()