note 51094 added to ref.exec
| From: | info at skyco dot de | Date: | Sat, 19 Mar 2005 16:13:26 +0000 |
| Subject: | note 51094 added to ref.exec | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-86689@lists.php.net to get a copy of this message | ||
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
?>
----
Manual Page -- http://www.php.net/manual/en/ref.exec.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+51094
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+51094&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+51094&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+51094&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+51094&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+51094&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+51094&report=yes
Search -- http://master.php.net/manage/user-notes.php