NYCPHP Meetup

NYPHP.org

[nycphp-talk] IPC Problems

Ben Sgro (ProjectSkyline) ben at projectskyline.com
Thu Apr 19 13:46:48 EDT 2007


Hello Chris, 

Ok, makes sense.

I tried having the child create its own DB connection (object)
which seems to work all right, until it executes the query,
at which point it says the DB is gone.

I'm trying something a bit different now, using two files, parent
and child and then using the queue to send messages back in forth,
such as, the childs PID (so the parent could kill it if it runs to long)
and the return value of the child (success of failure).

This way eliminates the fork and the reaping, as the child's just exit(0)
when they are done, or worse (haven't coded this yet), the parent can 
kill them (since it tracks the pids and job_ids).

Truthfully, I dont know what the easiest way to do this is, nor 
can I find any good documentation on IPC and php.

- Ben

----- Original Message ----- 
From: "csnyder" <chsnyder at gmail.com>
To: "NYPHP Talk" <talk at lists.nyphp.org>
Sent: Thursday, April 19, 2007 1:38 PM
Subject: Re: [nycphp-talk] IPC Problems


> Hi Ben,
> 
> It's been a couple years since I had to deal with forking processes
> and such, so I'm not up to debugging your code. But one thing that
> might help you simplify is to remember that, at the time of the fork,
> the child's environment is the same as the parent's.
> 
> If the parent loads the job record from the database into an array or
> object named $job, and then forks, the child will have its own copy of
> $job and can just go to work on it.
> 
> IIRC the database connection is a special case because it's a resource
> -- same goes for file pointers. Nevertheless, the child should have
> access to the username and password (in $dbSet?) to be able to make
> it's own connection to the db.
> 
> -- 
> Chris Snyder
> http://chxo.com/
> _______________________________________________
> 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



More information about the talk mailing list