NYCPHP Meetup

NYPHP.org

[nycphp-talk] fork (broadcast emailer: is this sane strategy)

Joel De Gan joel at tagword.com
Wed Aug 18 12:25:30 EDT 2004


Speaking of one of those comments (the one by me in particular).
That drove me insane for a long time, that comment will help save you a
"lot" of grief dealing with zombies that are generated by just following
the basic function reference.

-joeldg

On Wed, 2004-08-18 at 12:20, ophir prusak wrote:
> I've never had to use real forks in PHP thought I have in Perl.
> Using the PHP exec command doesn't do "real" forking, it just creates
> a new process in the background.
> If you want real forking use the pcntl_fork command.
> http://us3.php.net/manual/en/function.pcntl-fork.php
> The user comments are helpful
> 
> Ophir
> 
> David Mintz wrote:
> > I'm a total forkin' newbie, but I've read that with "real" forking, the OS
> > will make two identical copies of address spaces, one for the parent and
> > the other for the child. If parent has set $foo = 7 prior to the fork, the
> > child would see $foo = 7 as well.  Whereas in this example, we're just
> > launching another independent instance of ourself, and as such we start
> > with a clean slate.
> > 
> > True?
> > 
> > On Tue, 17 Aug 2004 drydell at att.net wrote:
> > 
> >   
> > > I'm not sure if it is or not, but it behaves in exactly the same way... I have several long running tasks that I can initiate from a web page, have the next page rendered in the browser immediately, and then watch the background tasks run from a UNIX shell...
> > > 
> > >     
> > > > Just as an aside, it's possible to fork a detached php process, all you need
> > > >       
> > > to do is turn off stdin and stdout (and you should trap output/errors to a log):
> > >     
> > > > exec("/path/to/php /your/script.php 2>>/your/logfile.log >&- <&-
> > > >       
> > > > > /your/logfile.log");
> > > > >         
> > > That's what I'm doing (I think). Although -- correct me if I'm wrong -- I
> > > believe technically that ain't true forking, as in pcntl_fork().
> > >     
> > 
> > 
> > ---
> > David Mintz
> > http://davidmintz.org/
> > 
> >         "Anybody else got a problem with Webistics?" -- Sopranos 24:17
> > _______________________________________________
> > New York PHP Talk
> > Supporting AMP Technology (Apache/MySQL/PHP)
> > http://lists.nyphp.org/mailman/listinfo/talk
> > http://www.newyorkphp.org
> >   
> 
> 
> 
> ______________________________________________________________________
> _______________________________________________
> New York PHP Talk
> Supporting AMP Technology (Apache/MySQL/PHP)
> http://lists.nyphp.org/mailman/listinfo/talk
> http://www.newyorkphp.org
-- 
joeldg - developer, Intercosmos media group.
http://lucifer.intercosmos.net




More information about the talk mailing list