Ben Sgro (ProjectSkyline) wrote: > Hi All, > > I'm trying to write a script, that forks children to each run a job, provided > by > the parent in the form of a job_id, passed by IPC msg_send( ). > > Now, when I run the job, I get some problems w/the DB loosing the connection. > I also have problems w/the job_id that's get passed ..sometimes, somehow, its > the > PID...I dont get it. > > It seems like the IPC is all over the place ... I've included the output from > the script, > the database tables, and the source of the script. > > Any help is greatly appreaciated. I've read the php.net pcntl_and msg- (IPC) > stuff over and over.
It sounds like you might be making this more complicated than it needs to be. > What the goal is: > 1) Parent, selects the next job to run. > 2) Marks job as active =1, stores the PID > 3) Forks off a child to run this (job_id passed to child via msg_send( )) The child can read the job_id from a variable set in the parent before the fork, why not just do this? > 4) Child runs, finishes job and marks as active = 0, incremenents run count, > tells parent to kill them Why does the child need the parent to kill them? A call to exit() at the end of the child section should do the trick just fine. > 5) Rinse lather repeat Hope this helps, Dan _______________________________________________ New York PHP Community Talk Mailing List http://lists.nyphp.org/mailman/listinfo/talk NYPHPCon 2006 Presentations Online http://www.nyphpcon.com Show Your Participation in New York PHP http://www.nyphp.org/show_participation.php
