I&#39;m trying to speed up some processing in a script.  Currently, the script has a set of subroutines it runs through in sequence, some take only a second to run, others can run for minutes.  Meanwhile the multi-core system is only using one CPU and the others are idle.<br>

<br>What I&#39;d like to do is have the parent process fork a number of children processes and wait for one to complete, then start another child to work on the next remaining subroutine.  I&#39;ve got the forking routine down and I can get multiple children running at one time, but waiting for any one of them to complete has me stumped.<br>

<br>I&#39;ve tried using &quot;waitpid(-1,WNOHANG)&quot; thinking that would return the PID of the last child to die, or &quot;-1&quot; if none had died since last checking, but that seems to just hang _waiting_ for the next death to happen...   I did a &quot;waitpid($pid_of_a_child, 0)&quot; but tha just waits until that specific child dies.<br>

<br>Anyone have any example code that can do this?<br><br>Thanks,<br><br>Dan<br><br clear="all">&quot;Quis custodiet ipsos custodes?&quot; (Who can watch the watchmen?) -- from the Satires of Juvenal<br>&quot;I do not fear computers, I fear the lack of them.&quot; -- Isaac Asimov (Author)<br>

** *** ***** ******* *********** *************<br>