Re: process creation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I have achieved this by using curl_exec() to issue another HTTP request on 
the same server. By setting the timeout to a small number I regain control 
and can continue with other things while the new process runs to completion. 
Here is my code:

    $url = 'HTTP://' .$_SERVER['HTTP_HOST'] .'/newprocess.php';
    // launch this script in another server process, but let it run
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
    curl_setopt($ch, CURLOPT_TIMEOUT, 2);

    $content = curl_exec($ch);
    if ($content === FALSE) {
        $curl_errno = curl_errno($ch);
        if ($curl_errno == 28) {
            // timeout - ignore
        } else {
         $curl_error = curl_error($ch);
         $errors[] = "CURL error $curl_errno: $curl_error";
        } // if
    } // if
    curl_close($ch);

Hope this helps.

-- 
Tony Marston
http://www.tonymarston.net
http://www.radicore.org

""bruce"" <bedouglas@xxxxxxxxxxxxx> wrote in message 
news:156301c97d82$b33698d0$0301a8c0@xxxxxxxxxxxx
>A simple question (or so I thought).
>
> Does php allow an app to create/start a process/application that can
> continue to run on its own, after the initiating program/app terminates?
>
> It appears that the spawning/forking functions might work, but the child
> apps would be in a zombie status, and couldn't be killed by an external
> program.
>
> Basically, I'd like to create a bunch of test apps/processes, and then to 
> be
> able to kill them by a separate process if the apps take too long to run..
>
> So.. thoughts/comments would be appreciated!
>
> thanks
>
> 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux