NYCPHP Meetup

NYPHP.org

[nycphp-talk] building an 1-way email list manager

Anthony Papillion papillion at gmail.com
Tue Nov 15 17:15:53 EST 2005


So then, the ideal way to handle a long running process might be to use cron
and execute a CLI script, right? Because that would be totally independent
of the Apache process and is fairly simple (if unelegant) to use.

Anthony

On 11/15/05, Hans Zaunere <lists at zaunere.com> wrote:
>
>
>
> Anthony Papillion wrote on Tuesday, November 15, 2005 4:31 AM:
> > This discussion triggers a question that I'm sure someone here can
> > answer: wouldn't forking the script to the background allow one to
> > send a huge volume of email without a timeout?
>
> It would, but forking can be a bit of an art.
>
> For any long running process that you wish to spawn out of PHP running
> under
> Apache (as a DSO anyway) you need to cut ties with Apache. When a fork()
> is
> done, the file descriptors are copied as well, meaning that now your PHP
> script is sharing stdout/stdin/stderr with Apache. The implication of this
> is that your script is now waiting for input/output just like Apache, and
> more importantly, Apache is waiting for your script.
>
> So in order to correctly - and completely - fork, you need to fork(), kill
> child, fork() again (creating a new process group), and most importantly,
> close and reopen file descriptors in the PHP process. How to do this
> correctly varies a little between flavors of Linux/BSD/etc.
>
>
> ---
> Hans Zaunere / President / New York PHP
> www.nyphp.org <http://www.nyphp.org> / www.nyphp.com<http://www.nyphp.com>
>
>
> _______________________________________________
> New York PHP Talk Mailing List
> AMP Technology
> Supporting Apache, MySQL and PHP
> http://lists.nyphp.org/mailman/listinfo/talk
> http://www.nyphp.org
>



--
Anthony Papillion
Phone: (918) 926-0139
ICQ: 96-698-595

CAN ONE VOICE CHANGE THE WORLD?
http://www.one.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20051115/be3b9e05/attachment.html>


More information about the talk mailing list