summaryrefslogtreecommitdiff
path: root/inc/io.php
diff options
context:
space:
mode:
authorTom N Harris <tnharris@whoopdedo.org>2010-11-16 17:58:28 -0500
committerTom N Harris <tnharris@whoopdedo.org>2010-11-16 17:58:28 -0500
commit6c528220aaf62f4ba5890483797d6661352500bb (patch)
treece26e10e6c845a249549db649b8576cbaf604857 /inc/io.php
parent5bcab0c47360e5b31237885cff4583e0eba479f8 (diff)
downloadrpg-6c528220aaf62f4ba5890483797d6661352500bb.tar.gz
rpg-6c528220aaf62f4ba5890483797d6661352500bb.tar.bz2
Repurpose io_runcmd for pipes
Diffstat (limited to 'inc/io.php')
-rw-r--r--inc/io.php23
1 files changed, 13 insertions, 10 deletions
diff --git a/inc/io.php b/inc/io.php
index 1d69dabc9..9b797ebf2 100644
--- a/inc/io.php
+++ b/inc/io.php
@@ -533,17 +533,20 @@ function io_rename($from,$to){
*
* @author Harry Brueckner <harry_b@eml.cc>
* @author Andreas Gohr <andi@splitbrain.org>
- * @deprecated
*/
-function io_runcmd($cmd){
- $fh = popen($cmd, "r");
- if(!$fh) return false;
- $ret = '';
- while (!feof($fh)) {
- $ret .= fread($fh, 8192);
- }
- pclose($fh);
- return $ret;
+function io_runcmd($cmd, $input, &$output){
+ $descspec = array(
+ 0=>array("pipe","r"),
+ 1=>array("pipe","w"),
+ 2=>array("pipe","w"));
+ $ph = proc_open($cmd, $descspec, $pipes);
+ if(!$ph) return -1;
+ fclose($pipes[2]); // ignore stderr
+ fwrite($pipes[0], $input);
+ fclose($pipes[0]);
+ $output = stream_get_contents($pipes[1]);
+ fclose($pipes[1]);
+ return proc_close($ph);
}
/**