running process in the background
| From: | Georgi Ivanov | Date: | Wed, 31 Aug 2005 16:44:09 +0000 |
| Subject: | running process in the background | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-221655@lists.php.net to get a copy of this message | ||
Hi,
I'm experiencing strange behavior when trying to run background process in
PHP.
Code :
//Run_check.php
foreach ($_POST as $kid){
php run.php param1 param2 > /dev/null &;
}
In this case PHP waits all the instances of the process to complete.
I don't understand why.
I have a workaround here, but anyway i don't understand why the above example
doesn't work.
If i don't run the cycle here , but run other file and there run the cycle
that runs the the background processes everything is OK.
------------------------------------
/*This file gets $_POST , implodes it , and passes the string to the other
script */
//Run_check.php
$ids=implode(',',$_POST);
php run1.php $ids;
------------------------------------
------------------------------------
/*This script takes the input , explodes it and runs a cycle that runs the
background process*/
//run1.php :
$kwid=explode(',',$argv[1]);
foreach ($kwid as $kid){
php run.php param1 param 2 > /dev/null &;
}
------------------------------------
Everything is OK.