Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ruby: wait for any child process to finish

Tags:

ruby

Is there a way to wait for any (not all!) child process to finish? I am writing a Rake task that spawns several child processes and I want to start an action as soon as the first child process is finished.

like image 924
Andrew Bezzub Avatar asked Oct 22 '25 08:10

Andrew Bezzub


1 Answers

Just call

Process.wait

With no arguments. This waits for any child process to terminate (see docs)

You can also wait for children of a specific process group - possibly useful if you need more control.

like image 94
Frederick Cheung Avatar answered Oct 23 '25 21:10

Frederick Cheung



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!