3 error_reporting(E_ALL
);
5 $php = getenv('TEST_PHP_EXECUTABLE');
7 die("No php executable defined\n");
9 $cmd = 'php -r "fwrite(STDOUT, $in = file_get_contents(\'php://stdin\')); fwrite(STDERR, $in);"';
10 $descriptors = array(array('pipe', 'r'), array('pipe', 'w'), array('pipe', 'w'));
11 $stdin = str_repeat('*', 1024 * 16) . '!';
12 $stdin = str_repeat('*', 2049 );
14 $options = array_merge(array('suppress_errors' => true, 'binary_pipes' => true, 'bypass_shell' => false));
15 $process = proc_open($cmd, $descriptors, $pipes, getcwd(), array(), $options);
17 foreach ($pipes as $pipe) {
18 stream_set_blocking($pipe, false);
20 $writePipes = array($pipes[0]);
21 $stdinLen = strlen($stdin);
26 while ($pipes ||
$writePipes) {
30 $n = stream_select($r, $w, $e, 60);
35 proc_terminate($process);
39 $written = fwrite($writePipes[0], (binary
)substr($stdin, $stdinOffset), 8192);
40 if (false !== $written) {
41 $stdinOffset +
= $written;
43 if ($stdinOffset >= $stdinLen) {
44 fclose($writePipes[0]);
49 foreach ($r as $pipe) {
50 $type = array_search($pipe, $pipes);
51 $data = fread($pipe, 8192);
52 if (false === $data ||
feof($pipe)) {