On 9/28/06, Phy Prabab <phyprabab / yahoo.com> wrote: > Folks, > > Can someone shed some light on how I can accomplish something similar to this: > > exec("foo action") > exec("foobar action") > Process.wait > > I want to wait on the second process, yet in ruby 184, all processes are waited on (until completion). How can I effectively fork off these process simultaneously and wait for the last one to complete or what would be really nice, is to wait for both of these separate processes to finish. First of all, exec replaces the current process with an external command. Also Process.wait (if you got to it, which you wouldn't after exec) wait's for any child process to terminate. Now assuming that "foo action" and "foobar action" are ruby expressions and not external commands I thing you want something like this: child_pid1 = fork { foo action } child_pid2 = fork {foobar action} child_pid1 and child_pid2 will be the process id's of the respective children. Now you can do a variety of things as far as waiting for the processes to end including: # wait for any child to exit and return it's process id child_pid = Process.wait # wait for all children to exit and return an array of the form: # [[pid1, status1], ...] status_arrays = Process.wait_all # wait for any child to exit and return an array containing the child # processes pid and status status_array = Process.wait2 # wait for a specific child process waitpid(child_pid1) -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/