From: Martin DeMello Date: 2006-11-13T23:18:16+09:00 Subject: waiting for multiple child processes to finish Why does this not work (it waits for each process to finish before launching the next): ------------------------------------------------------------- $stdout.sync = true 10.times {|i| pid = Process.fork { puts "launching process #{i}" 3.times { sleep 0.5 puts "hello from process #{i}" } } Thread.new { Process.waitpid(pid) }.join } puts "done!" ------------------------------------------------------------- but this does: ------------------------------------------------------------- $stdout.sync = true pids = [] 10.times {|i| pids << Process.fork { puts "launching process #{i}" 3.times { sleep 0.5 puts "hello from process #{i}" } } } pids.each {|pid| Thread.new { Process.waitpid(pid) }.join } puts "done!" -------------------------------------------------------------