php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48684 cant make STDIN non blocking
Submitted: 2009-06-25 04:49 UTC Modified: 2009-12-20 01:00 UTC
Votes:3
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:2 (100.0%)
From: ryan at ryanmills dot net Assigned:
Status: No Feedback Package: Streams related
PHP Version: 5.2.10 OS: win32 only - Vista X64
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: ryan at ryanmills dot net
New email:
PHP Version: OS:

 

 [2009-06-25 04:49 UTC] 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.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-06-25 22:43 UTC] ryan at ryanmills dot net
tested on linux and 32bit windows. Linux works, windows does not.
 [2009-10-20 23:32 UTC] ron at rongage dot org
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
 [2009-12-08 20:59 UTC] spam at helper3000 dot net
Problem experianced using 5.3.1 in both thread and non-thread safe binaries on windows XP SP2.

I too have read that it is an ongoing problem; it should have been fixed many years ago.
 [2009-12-11 22:43 UTC] spam at helper3000 dot net
Would also just like to add that after a mere day, a busy friend I know managed to fix PHP 5.2 and apply the patch to 5.3, it now works perfectly using his modified build.
UNDER A DAY. And this issue has been continuing in PHP for at least 7 years...
 [2009-12-11 22:46 UTC] pajoye@php.net
And where is the patch then?
 [2009-12-12 02:00 UTC] spam at helper3000 dot net
http://rapidshare.com/files/319636981/php-5.3.1L.zip.html

He's refining it more and as so includes no source.
 [2009-12-12 02:17 UTC] pajoye@php.net
Ok, please provide a link to the patch once you are ready, pastie.org will do it, not a website where we have to register to fetch it.
 [2009-12-20 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 15:01:28 2024 UTC