[nycphp-talk] fork (broadcast emailer: is this sane strategy)
David Mintz
dmintz at davidmintz.org
Tue Aug 17 09:46:57 EDT 2004
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
More information about the talk
mailing list