Forum Moderators: coopster
noSanity
If you want only ten concurrently running children then keep a variable which stores the number of alive children. Increase that number when you successfully pcntl_fork [php.net] a new child.
To keep track of died children and reap´em when they die - as any good parent will do - use pcntl_signal [php.net] to install a SIGCHLD handler which will reap your children.
In that reaper function loop while pcntl_waitpid [php.net] is true. Make sure that you use -1 for the PID parameter which will wait for any children and WNOHANG as the options parameter to return immediately if there are no dead children to reap. In that loop decrease your number of running children by one.
Andreas