Re: proc_open fclose streams..

From: Date: Mon, 10 Dec 2007 02:29:06 +0000
Subject: Re: proc_open fclose streams..
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-265594@lists.php.net to get a copy of this message
Nathan Rixham wrote:
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 think that's controlled by the process you're calling rather than a php thing. For example, smtp connections do this until you enter a '.' on a single line. ie the process you're calling doesn't know when to stop reading from stdin until you close the conn. -- Postgresql & php tutorials http://www.designmagick.com/

« previous php.general (#265594) next »