php-src/sapi/cli/tests/std_streams.phpt
Nikita Popov 9ec61e43d4 Fix pipe detection and stream position handling
There are two related changes here:
1. Also check for S_ISCHR/FILE_TYPE_CHAR when checking for pipes, so
   that we detect ttys as well, which are also not seekable.
2. Always set position=-1 (i.e. ftell will return false) when a pipe
   is detected. Previously position=0 was sometimes used, depending on
   whether we're on Windows/Linux and whether the FD or FILE codepath
   was used.
2019-09-05 18:29:15 +02:00

31 lines
540 B
PHP

--TEST--
Testing ftell() on std streams
--SKIPIF--
<?php
if (getenv("SKIP_IO_CAPTURE_TESTS")) {
die("skip I/O capture test");
}
?>
--CAPTURE_STDIO--
STDOUT
--FILE--
<?php
// These have proc_open pipes attached
var_dump(ftell(STDIN));
var_dump(ftell(STDERR));
var_dump(ftell(fopen("php://stdin", "r")));
var_dump(ftell(fopen("php://stderr", "w")));
// These have a tty attached
var_dump(ftell(STDOUT));
var_dump(ftell(fopen("php://stdout", "w")));
?>
--EXPECT--
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)