From: Hugh Sasse Date: 2006-11-21T05:45:02+09:00 Subject: Re: fork, trap and exec. Pickaxe typo? On Tue, 21 Nov 2006, Nate Murray wrote: > Yeah, but how do I wait for an unknown amount of time? It would seem > that this would do it: > > trap("CLD") { > pid = Process.wait > puts "Child pid #{pid}: terminated" > } > > 1.upto(4) do > fork do > exec("sleep 3 && echo \"hello $HOSTNAME #{Process.pid}\n\"") > end > end > > Process.waitall puts Process.waitall =begin ri_output ------------------------------------------------------- Process::waitall Process.waitall => [ [pid1,status1], ...] ------------------------------------------------------------------------ Waits for all children, returning an array of _pid_/_status_ pairs (where _status_ is a +Process::Status+ object). [...] =end # So while I'm not sure what's happening to the missing signal # you should be able to see that all the processes have finished. > > But trap isnt always called on all the children. > > Example output: > [...] > Notice that 4137 never called the trap callback even though > Process.waitall was called. > Hugh