Pcntl_fork() fun-ness

Alright, so this ones for my peeps who have experience forking new processes.

I have yet to write a script that does it, but I do get the general idea behind it, how it copies its self etc. My obstacle is that I need a way to either pass a variable or alter something so that I can make each process run something different.

Lets assume I want to create 10 children to run an operation on table. I would like each process to run its operation base don the last digit in the id ( 0-10, 10 processes :wink: ). How might one achieve some sort of incrementation to pass to the children so that they are not running on the same term digit, short of using a db table to store and check for who’s working on what.

Just found this guy: http://www.php.net/manual/en/shmop.examples-basic.php

I’ll be sure to let everyone know how it goes and share some sample classes

Do you need to know the state or result of the child processes? If not, a blind exec might be a cleaner way to do it and you don’t need to wait for the child to finish execution.

Absolutely I need to know the state of the child process. That wouldn’t be cleaner, it would just be less code :wink: