xref: /PHP-8.1/sapi/cli/tests/gh8827-001.phpt (revision 2dbde18b)
1--TEST--
2std handles can be deliberately closed 001
3--SKIPIF--
4<?php
5if (php_sapi_name() != "cli") {
6	die("skip CLI only");
7}
8if (PHP_OS_FAMILY == 'Windows') {
9	die("skip not for Windows");
10}
11if (PHP_DEBUG) {
12    die("skip std streams are not closeable in debug builds");
13}
14if (getenv('SKIP_REPEAT')) {
15    die("skip cannot be repeated");
16}
17?>
18--FILE--
19<?php
20print "STDIN:\n";
21fclose(STDIN);
22var_dump(@fopen('php://stdin', 'r'));
23
24print "STDERR:\n";
25fclose(STDERR);
26var_dump(@fopen('php://stderr', 'a'));
27
28print "STDOUT:\n";
29fclose(STDOUT);
30// not printed if stdout is closed
31var_dump(@fopen('php://stdout', 'a'));
32?>
33--EXPECT--
34STDIN:
35bool(false)
36STDERR:
37bool(false)
38STDOUT:
39