#16048 [Fbk->NoF]: fgets/feof failure when stdin is reading from a pipe

From: Date: Fri, 02 Aug 2002 05:00:10 +0000
Subject: #16048 [Fbk->NoF]: fgets/feof failure when stdin is reading from a pipe
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-15784@lists.php.net to get a copy of this message
ID: 16048 Updated by: php-bugs@lists.php.net Reported By: pjm@cctechnol.com -Status: Feedback +Status: No Feedback Bug Type: Filesystem function related Operating System: Solaris 2.7 & 2.8 PHP Version: 4.1.2 New Comment: No feedback was provided for this bug for over a month, so it is being suspended automatically. If you are able to provide the information that was originally requested, please do so and change the status of the bug back to "Open". Previous Comments: ------------------------------------------------------------------------ [2002-07-01 15:15:13] sander@php.net Sorry, I'm crazy tonight... #18022 is a dupe of this one... Just noting this url from #18022: http://marc.theaimsgroup.com/?l=php-general&m=101428004729977&w=2 ------------------------------------------------------------------------ [2002-07-01 15:13:40] sander@php.net This is actually a dupe of #8849. Please try the snapshot anyway but add your experiences to #8849. Thanks. ------------------------------------------------------------------------ [2002-07-01 15:10:48] sander@php.net Can't reproduce with the latest CVS. Can you try a snapshot from http://snaps.php.net to see if it's been fixed? ------------------------------------------------------------------------ [2002-03-13 17:29:53] pjm@cctechnol.com I also tested this on Red Hat 7.2 with PHP 4.0.6 It works fine there. ------------------------------------------------------------------------ [2002-03-13 17:00:20] pjm@cctechnol.com The fgets() function works differently when the input is a pipe. Specifically, feof() returns true after the first line is read. The test script and sample output follow. The test script works fine if stdin is redirected from a file. It fails if stdin is a pipe. Nothing special about the build: ./configure --prefix=/usr/local --with-mysql pjm@poseidon> cat test.php #!/usr/local/bin/php -q <?php $fd = fopen("php://stdin", "r"); while (! feof($fd)) { $buffer = fgets($fd, 4096); echo $buffer; } ?> pjm@poseidon> < test.php ./test.php #!/usr/local/bin/php -q <?php $fd = fopen("php://stdin", "r"); while (! feof($fd)) { $buffer = fgets($fd, 4096); echo $buffer; } ?> pjm@poseidon> cat test.php | ./test.php #!/usr/local/bin/php -q ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=16048&edit=1

« previous php.bugs (#15784) next »