proc_open fclose streams..

From: Date: Fri, 07 Dec 2007 13:39:47 +0000
Subject: proc_open fclose streams..
Groups: php.general 
Request: Send a blank email to php-general+get-265560@lists.php.net to get a copy of this message
Hi Guys, Hoping somebody out there may have come across this one, possible functionality request depending on responses. $descriptor = array( 0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("pipe", "w") ); $process = proc_open('mysql', $descriptor, $pipes); fwrite($pipes[0], 'show databases;'); echo stream_get_contents($pipes[1]); //won't work, crash, time out.. nothing returns as we need to.. fwrite($pipes[0], 'show databases;'); fclose($pipes[0]); // note the fclose echo stream_get_contents($pipes[1]); I don't want to fclose pipes[0] though, as i want to keep it open and keep writing to it, alternating with reading from pipes[1] and [2].. so a replacement for fclose, or an fflush on stdout that works? The problem appears to be that nothing is returned to php until the stdin pipe is closed, even if I write hundreds of commands to it. I'm on php 5.1.6/5.2.4 on various linux installs recap: spawn process, keep open for the duration of script execution, read and write multiple times to same process, then close - even better latch on to an already running process by id - any ideas methods etc? Cheers, Nathan

« previous php.general (#265560) next »