-
-
Save anonymous/c812e21d1244a8c137a8 to your computer and use it in GitHub Desktop.
PHP 5.6.9 stream_get_contents usage
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
20:49 starting | |
20:49 proc_open finished | |
22:19 stream_get_contents 1 finished | |
22:19 fclose 1 finished | |
22:19 stream_get_contents 2 finished | |
22:19 fclose 2 finished | |
22:19 proc_close finished | |
array(3) { | |
["stdout"]=> | |
string(3) "bla" | |
["stderr"]=> | |
string(0) "" | |
["exitCode"]=> | |
int(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 | |
printTimeStatus("starting"); | |
$command = '"'.PHP_BINARY.'" slowscript.php'; | |
$pipes = []; | |
$resource = proc_open($command, [1 => ["pipe", "w"], 2 => ["pipe", "w"]], $pipes); | |
printTimeStatus("proc_open finished"); | |
$stdout = stream_get_contents($pipes[1]); | |
printTimeStatus("stream_get_contents 1 finished"); | |
fclose($pipes[1]); | |
printTimeStatus("fclose 1 finished"); | |
$stderr = stream_get_contents($pipes[2]); | |
printTimeStatus("stream_get_contents 2 finished"); | |
fclose($pipes[2]); | |
printTimeStatus("fclose 2 finished"); | |
$exitCode = proc_close($resource); | |
printTimeStatus("proc_close finished"); | |
var_dump( ["stdout"=>$stdout, "stderr"=>$stderr, "exitCode"=>$exitCode] ); | |
function printTimeStatus($msg) | |
{ | |
print date("i:s") . " $msg\n"; | |
} |
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 | |
sleep(90); | |
print "bla"; |
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
20:52 starting | |
20:52 proc_open finished | |
21:27 stream_get_contents 1 finished | |
21:27 fclose 1 finished | |
22:03 stream_get_contents 2 finished | |
22:03 fclose 2 finished | |
22:22 proc_close finished | |
array(3) { | |
["stdout"]=> | |
string(0) "" | |
["stderr"]=> | |
string(0) "" | |
["exitCode"]=> | |
int(0) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment