From: [EMAIL PROTECTED] Operating system: Solaris 2.7 & 2.8 PHP version: 4.1.2 PHP Bug Type: Filesystem function related Bug description: fgets/feof failure when stdin is reading from a pipe
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 bug report at http://bugs.php.net/?id=16048&edit=1 -- Fixed in CVS: http://bugs.php.net/fix.php?id=16048&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=16048&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=16048&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=16048&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=16048&r=support Expected behavior: http://bugs.php.net/fix.php?id=16048&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=16048&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=16048&r=submittedtwice