Re: Problem with getting non-blocking data from stdin

From: Date: Sat, 20 Sep 2003 14:07:12 +0000
Subject: Re: Problem with getting non-blocking data from stdin
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-163290@lists.php.net to get a copy of this message
File a bug report. stream_set_blocking() started to work for files only since version 4.3, so it is likely full of bugs. Actualy, using cli php 4.3.2 I got this results some weird results. Your version run infinitely but changing echo 'Fooo!'."\n"; to echo 'Fooo!'; (removing newline) resulted in the same behavior as you experienced. fread did not return false even if no key was pressed, only empty string but this might be correct, i don't know. Both fgetc and fgets did return false. Robert Cummings wrote:
On Sat, 2003-09-20 at 02:02, Curt Zirzow wrote:
hmm.. on second thought... * Thus wrote Robert Cummings (robert@interjinn.com):
[...]
       if( ($char = fread( $stdin, 1 )) !== false )
How are you calling this script? I'm not sure how cgi will handle fread <stdin> With a traditional CGI script <stdin> is what is read on POST data from a form, and php takes care of this. That is where my confusion is now.
I'm calling it as "php -qC foo.php". The fread() should work since it works on input when I don't have stdin in non-blocking mode. Perhaps it's a bug. I took a look at the doc on streams again, and it uses php://input as the POST stream. Maybe it's a bug. Cheers, Rob.


« previous php.general (#163290) next »