Bug #66353 [Opn]: fgets unexpected behaviour in non-blocking mode

From: Date: Thu, 26 Dec 2013 12:16:48 +0000
Subject: Bug #66353 [Opn]: fgets unexpected behaviour in non-blocking mode
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-183465@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=66353&edit=1 ID: 66353 User updated by: an0nym at narod dot ru Reported by: an0nym at narod dot ru Summary: fgets unexpected behaviour in non-blocking mode Status: Open Type: Bug Package: Streams related Operating System: Linux, BSD PHP Version: 5.5.7 Block user comment: N Private report: N New Comment: A more precise description: in non-blocking mode fgets should buffer data it read from stream and immediately return until it meets eol or eof. Previous Comments: ------------------------------------------------------------------------ [2013-12-26 10:12:22] an0nym at narod dot ru Description: ------------ In non-blocking mode fgets should buffer data it read from stream until it meets eol or eof instead of returning anything it read. Test script: --------------- $ cat test1.php <?php fwrite(STDOUT, 'test1'); sleep(5); fwrite(STDOUT, "\n"); sleep(5); fwrite(STDOUT, "test2\n"); $ cat test2.php <?php stream_set_blocking(STDIN, false); do { $test = fgets(STDIN); if ($test) { var_dump($test); } } while (!feof(STDIN)); $ php55 test1.php | php55 test2.php Expected result: ---------------- string(6) "test1 " string(6) "test2 " Actual result: -------------- string(5) "test1" string(1) " " string(6) "test2 " ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=66353&edit=1

« previous php.bugs (#183465) next »