ID:               48684
 Comment by:       ron at rongage dot org
 Reported By:      ryan at ryanmills dot net
 Status:           Open
 Bug Type:         Streams related
 Operating System: win32 only - Vista X64
 PHP Version:      5.2.10
 New Comment:

Actually, it still doesn't work on Linux either (5.2.11).

Yes, the actual fread is non-blocking.  However, if you press any key,
it is NOT registered so you can't react to keystrokes.

The code:
<?php
stream_set_blocking(STDIN,FALSE);
while (1)
  {
  $x = fread(STDIN,1);
  var_dump($x);
  if ($x != "")
    exit;
  }

As expected with non-blocking, the fread doesn't hold up execution of
the program.  However, if a key is hit (something comes in on STDIN),
the program should immediately exit.  It doesn't - it just keeps on
going, and going, and going....

Ron


Previous Comments:
------------------------------------------------------------------------

[2009-06-25 22:43:30] ryan at ryanmills dot net

tested on linux and 32bit windows. Linux works, windows does not.

------------------------------------------------------------------------

[2009-06-25 04:49:01] ryan at ryanmills dot net

Description:
------------
I have read a number of past bug reports from 2002 to just a month or
two ago. Under windows it does not seem that you can make STDIN non
blocking.

Follow code from: http://bugs.php.net/bug.php?id=47893&edit=2

Tested on 5.2.9-2 and 5.2.10

Notes say it was fixed in CVS so I assume 5.2.10 would have had the
fix.


*NOTE php.ini changes

;;;;;;;;;;;;;;;;;;;
; Resource Limits ;
;;;;;;;;;;;;;;;;;;;

max_execution_time = 0   ; Maximum execution time of each script, in
seconds
max_input_time = 0      ; Maximum amount of time each script may spend
parsing request data
;max_input_nesting_level = 64 ; Maximum input variable nesting level
memory_limit = 512M      ; Maximum amount of memory a script may
consume (128MB)



Reproduce code:
---------------
<?php
stream_set_blocking(STDIN, FALSE);
while (1) {
var_dump(fread(STDIN,1));
echo "\n";;
}
?>

Expected result:
----------------
A never-ending sequence of var_dumps of either an empty string or a
typed character

Actual result:
--------------
stuck waiting for the user to press enter.


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=48684&edit=1

Reply via email to