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"" <[email protected]> wrote in message
news:[email protected]...
>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