mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00

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.
31 lines
540 B
PHP
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)
|