123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- --TEST--
- std handles can be deliberately closed 003
- --SKIPIF--
- <?php
- if (php_sapi_name() != "cli") {
- die("skip CLI only");
- }
- if (PHP_OS_FAMILY == 'Windows') {
- die("skip not for Windows");
- }
- if (PHP_DEBUG) {
- die("skip std streams are not closeable in debug builds");
- }
- if (getenv('SKIP_REPEAT')) {
- die("skip cannot be repeated");
- }
- ?>
- --FILE--
- <?php
- $stdoutStream = fopen('php://stdout', 'r');
- $stdoutFile = tempnam(sys_get_temp_dir(), 'gh8827');
- $stderrFile = tempnam(sys_get_temp_dir(), 'gh8827');
- register_shutdown_function(function () use ($stdoutFile, $stderrFile) {
- unlink($stdoutFile);
- unlink($stderrFile);
- });
- fclose(STDOUT);
- fclose(STDERR);
- $stdoutFileStream = fopen($stdoutFile, 'a');
- $stderrFileStream = fopen($stderrFile, 'a');
- print "Goes to stdoutFile\n";
- file_put_contents('php://fd/1', "Also goes to stdoutFile\n");
- file_put_contents('php://fd/2', "Goes to stderrFile\n");
- ob_start(function ($buffer) use ($stdoutStream) {
- fwrite($stdoutStream, $buffer);
- }, 1);
- print "stdoutFile:\n";
- readfile($stdoutFile);
- print "stderrFile:\n";
- readfile($stderrFile);
- ?>
- --EXPECT--
- stdoutFile:
- Goes to stdoutFile
- Also goes to stdoutFile
- stderrFile:
- Goes to stderrFile
|