-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Showing
2 changed files
with
52 additions
and
31 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
--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) |