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