[urgent] proc_open, buffers, blocking help? thankyou please
Posted: Thu Dec 06, 2007 3:51 pm
Hoping somebody out there may have come across this one..
doesn't work as we need to..
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.. here's what I've tried with no success
none of the above in any order work for me.. php 5.1.6/5.2.4/ linux boxes
trying to:
spawn process, keep open for the duration of script execution, read and write multiple times to same process, then close - how?
the problem with the aforementioned method.
nothing returns to stdout until an fclose happens on stdin, so need a method of forcing this to happen without closing stdin
notes: i'm aware stream_get_contents looks for an eof, however I've tried all fget methods etc and there is 0 data in std out until stdin has been closed.
thanks in advance
Code: Select all
$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
//........Code: Select all
$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;');
fclose($pipes[0]); // note the fclose
echo stream_get_contents($pipes[1]); // works
// .................so a replacement for fclose.. here's what I've tried with no success
Code: Select all
fwrite($pipes[0], 'show databases;'."\n");
##################
fflush($pipes[0]);
##################
stream_set_write_buffer($pipes[0], 0);
##################
stream_set_blocking($pipes[0], false);
##################trying to:
spawn process, keep open for the duration of script execution, read and write multiple times to same process, then close - how?
the problem with the aforementioned method.
nothing returns to stdout until an fclose happens on stdin, so need a method of forcing this to happen without closing stdin
notes: i'm aware stream_get_contents looks for an eof, however I've tried all fget methods etc and there is 0 data in std out until stdin has been closed.
thanks in advance