note 51094 deleted from ref.exec by googleguy
| From: | googleguy@php.net | Date: | Tue, 22 Oct 2013 10:16:47 +0000 |
| Subject: | note 51094 deleted from ref.exec by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-196970@lists.php.net to get a copy of this message | ||
Note Submitter: info at skyco dot de
----
I noticed that a couple of contributers planned on having threads running in background while
operation continues.
If you have a script that will function for itself there is an easy solution: call it through
fsockopen (request to webserver) and do not wait for the answer. To make sure process is called
correctly on all operating systems I had to add an fgets but break after first couple of bytes.
example main script
<?php
echo "This is main thread, returning immediately";
$fp = fsockopen( <addyourcalltoscript> );
//fputs($fp, <yourvariablestosend>);
while(!feof($fp)){
fgets($fp, 128);
break;
}
fclose($fp);
?>
example child script
<?php
// make sure script runs without stopping //
set_time_limit(0);
ignore_user_abort(true);
// your code
?>