Created
August 31, 2013 15:25
-
-
Save matsu-chara/6398904 to your computer and use it in GitHub Desktop.
https://bugs.php.net/bug.php?id=51800
のSTDERR使わない版
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$data = str_repeat("a", 1024*1024); | |
fwrite(STDOUT, $data); | |
fwrite(STDERR, $data); | |
exit(0); | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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