Bug #76321 [Nab]: ftell(STDIN) returns 0 when no stdin is supplied

From: Date: Fri, 11 May 2018 23:16:35 +0000
Subject: Bug #76321 [Nab]: ftell(STDIN) returns 0 when no stdin is supplied
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-215228@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=76321&edit=1 ID: 76321 Updated by: requinix@php.net Reported by: gadelat at gmail dot com Summary: ftell(STDIN) returns 0 when no stdin is supplied Status: Not a bug Type: Bug Package: Filesystem function related Operating System: Windows 10 PHP Version: 7.2.5 Block user comment: N Private report: N New Comment: https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/ftell-ftelli64 > On devices incapable of seeking (such as terminals and printers), or when stream does not refer > to an open file, the > return value [of ftell] is undefined. Previous Comments: ------------------------------------------------------------------------ [2018-05-11 22:15:47] gadelat at gmail dot com This snippet works as expected on Windows 7. So this is regression and is IMHO worth investigation what's going on in windows 10 so this keep working across windows versions ------------------------------------------------------------------------ [2018-05-10 22:30:21] requinix@php.net If your application needs to process stdin and there isn't anything already in the buffer for it, it should wait. It sits and reads and/or waits until EOF. That's how filters normally operate. I'm not the most familiar with the subject but none of the tactics I just tried work. You might be out of luck. ------------------------------------------------------------------------ [2018-05-10 22:04:41] gadelat at gmail dot com My application revolves around processing STDIN. As a first step I validate input. I check if user supplied stdin and exit if didn't. So is there no way to check for STDIN presence on Windows without hanging whole application? ------------------------------------------------------------------------ [2018-05-10 21:56:19] requinix@php.net That won't prevent there from being a stdin. You aren't using it, but it's still there. As for Linux, stdin is a FIFO (glorified buffer) and you can't ftell on a FIFO. Why is having stdin a problem? ------------------------------------------------------------------------ [2018-05-10 21:34:37] gadelat at gmail dot com Running the script via php test.php from cmd.exe, powershell or git bash. Tried both thread safe and non-thread safe php 7.2.5 versions. I'm doing it via Virtualbox. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=76321 -- Edit this bug report at https://bugs.php.net/bug.php?id=76321&edit=1

« previous php.bugs (#215228) next »