Skip to content

Instantly share code, notes, and snippets.

@matsu-chara
Created August 31, 2013 15:25
Show Gist options
  • Save matsu-chara/6398904 to your computer and use it in GitHub Desktop.
Save matsu-chara/6398904 to your computer and use it in GitHub Desktop.
https://bugs.php.net/bug.php?id=51800 のSTDERR使わない版
<?php
$data = str_repeat("a", 1024*1024);
fwrite(STDOUT, $data);
fwrite(STDERR, $data);
exit(0);
?>
<?php
$cmd = "\"C:/xampp/php/php.exe\" process.php";
$status;
$stdout = "";
$pipes = array();
$descriptors = array(
0 => array("pipe", "r"), // stdin
1 => array("pipe", "w"), // stdout
);
$process = proc_open($cmd, $descriptors, $pipes);
if (is_resource($process))
{
fclose($pipes[0]);
while (!feof($pipes[1]))
$stdout .= fread($pipes[1], 1024);
fclose($pipes[1]);
$status = proc_close($process);
}
print_r(array(
"status" => $status,
"stdout" => $stdout,
));
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment