Re: process creation
| From: | Tony Marston | Date: | Fri, 23 Jan 2009 18:16:39 +0000 |
| Subject: | Re: process creation | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-287050@lists.php.net to get a copy of this message | ||
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@earthlink.net> wrote in message
news:156301c97d82$b33698d0$0301a8c0@tmesa.com...
>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
>
>