summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdrian Rossouw2009-02-04 14:05:32 +0000
committeradrian2009-02-04 14:05:32 +0000
commit29dde37d3f55fe588d37949b19f7d2a116ce9382 (patch)
tree0e59b491184e44df8bbfc9ae63021b9cc628a649
parente1f191bc578da4c937a1604a397ef52f193992b0 (diff)
Use blocking stream IO and manage feof and timedout status better. This will allow us to more cleanly extract information from sites and removes the possibility of the called scripts hanging6.x-0.1
-rw-r--r--provision.inc10
1 files changed, 8 insertions, 2 deletions
diff --git a/provision.inc b/provision.inc
index a52e428..b16904d 100644
--- a/provision.inc
+++ b/provision.inc
@@ -649,9 +649,14 @@ function provision_proc_open($cmd, &$data = NULL) {
}
fclose($pipes[0]);
$info = stream_get_meta_data($pipes[1]);
+ stream_set_blocking($pipes[0], TRUE);
stream_set_timeout($pipes[1], 1);
- while (! ($string = stream_get_contents($pipes[1]))) {
- sleep(1);
+ $stream = '';
+ while (!feof($pipes[1]) && !$info['timed_out']) {
+ $string .= fgets($pipes[1], 4096);
+ $info = stream_get_meta_data($pipes[1]);
+ ob_flush();
+ flush();
};
fclose($pipes[1]);
$code = proc_close($process);
@@ -661,6 +666,7 @@ function provision_proc_open($cmd, &$data = NULL) {
}
+
/**
* Run an external provision script and integrate it's output
*/