[UPHPU] Forking A Script [SOLVED]

Scott Hill llihttocs at gmail.com
Mon Jul 23 15:29:12 MDT 2007


On 7/23/07, Ken Snyder <ksnyder at coremr.com> wrote:
>
> Yay!! After more googling for "php background processing" and lots of
> testing, I found a working cross-platform background-processing method
> using functions popen() and pclose().  (Never heard of those
> functions!)  It relies on the command line ampersand concept.
>
> Explained here:
>
> http://robert.accettura.com/archives/2006/09/14/asynchronous-processing-with-php/
>
> See below for the heart of the idea.  Now if we can just spread the
> word--this is a question that has come up on a zillion forums!
>
> -- Ken
>
>
> if (is_windows()) {
>   // windows uses "start /b"
>   pclose(popen('start /b ' . $call, 'r'));
> } else {
>   // *nix uses "/dev/null &"
>   pclose(popen($call . ' /dev/null &', 'r'));
> }
> echo "<p>Called &quot;$call&quot; without waiting for a return value</p>";


Unix programmers should know about this.  It's a pipe.  It's part of *nix
InterProcess Communication (IPC) library.  I didn't realize PHP had this
functionality.  Check out man pages for Standard I/O functions (3S) popen
and pclose.

-- 
Scott Hill

"May you solve interesting problems" - Author Unknown
"A fanatic is one who can't change his mind and won't change the subject." -
Sir Winston Churchill


More information about the UPHPU mailing list