#19944 [Ctl]: fgets() returns garbage when STDIN set to non-blocking
| From: | wez@php.net | Date: | Sat, 19 Oct 2002 10:35:49 +0000 |
| Subject: | #19944 [Ctl]: fgets() returns garbage when STDIN set to non-blocking | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-22830@lists.php.net to get a copy of this message | ||
ID: 19944
Updated by: wez@php.net
Reported By: ces@vaultbbs.com
Status: Critical
Bug Type: Sockets related
Operating System: RedHat 7.3
PHP Version: 4.3.0-pre1
New Comment:
I've just committed a fix for the STDIN problem;
please try the next snapshot (dated/timestamped after
this message).
Please also test with sockets.
Previous Comments:
------------------------------------------------------------------------
[2002-10-19 04:27:16] wez@php.net
Can you provide a backtrace for the core-dump?
------------------------------------------------------------------------
[2002-10-18 20:11:55] ces@vaultbbs.com
Rats, just changing status to "Open"--already added comment above...
------------------------------------------------------------------------
[2002-10-18 20:11:03] ces@vaultbbs.com
As of snap-200210181500 it still doesn't work. Results are the same
with garbage returned when using fgets() on STDIN when in non-blocking
mode.
Last two snaps I've tried (10/17 and 200210181500) have the added
feature of also core dumping when fgets() is used on a non-blocking
socket opened with fsockopen(). Previous versions of PHP work as
expected with fgets() on a non-blocking socket, but the snaps seem to
core dump. 10/17 snap would core dump on first call to fgets() whereas
today's snap seems to go through the while loop three times and then
core dumps when it hits fgets() again.
Thus, the current observation is that when using fgets in non-blocking
mode:
1. STDIN returns garbage.
2. Sockets core dump.
------------------------------------------------------------------------
[2002-10-17 21:59:58] wez@php.net
As an aside:
you can use stream_select() to acheive this (see docs for
socket_select; they work the same way, but on different things).
Also, you should use if ($string !== false) to 100% correct in your
script.
------------------------------------------------------------------------
[2002-10-17 17:07:37] sniper@php.net
Try this one again: http://snaps.php.net/php4-latest.tar.bz2
You might have got the snapshot which didn't have the fixes.
------------------------------------------------------------------------
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
http://bugs.php.net/19944
--
Edit this bug report at http://bugs.php.net/?id=19944&edit=1