|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #62723 stream_select returns when there is output, not when state changes
Submitted: 2012-08-02 09:23 UTC Modified: 2012-11-15 16:47 UTC
From: thuejk at gmail dot com Assigned:
Status: Not a bug Package: Streams related
PHP Version: 5.3.15 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: thuejk at gmail dot com
New email:
PHP Version: OS:


 [2012-08-02 09:23 UTC] thuejk at gmail dot com
The documentation for stream_select() says ( )

"The stream_select() function accepts arrays of streams and waits for them to 
change status."

But that is not true. stream_select will return immediately if the read buffer of 
a stream is non-empty. The read buffer does not have to change status or length 
for stream_select() to return.

Obviously the current behaviour of stream_select() is correct, and the 
documentation is wrong. The current behaviour is also how select() (which the 
documentation says stream_select behaves like) works.

Test script:

function my_passthru2() {
  $cmd = sprintf("echo a;sleep 100000");
  $stream = popen($cmd, "r");
  $stream_array = Array($stream);
  $dummy_array = null;
  echo "after sleep";
  stream_select($stream_array, $dummy_array, $dummy_array, 10);
  echo "after select!";



Expected result:
Following the documentation: "after select!" should be printed 10 seconds after 
"after sleep", since the stream does not change status after stream_select is 
called (the read buffer will always contain "a").

Actual result:
"after select!" is printed immediately after "after sleep".


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2012-11-15 12:11 UTC]
-Status: Open +Status: Not a bug
 [2012-11-15 12:11 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

This is expected, you are not working with sockets but streams, it is correct that 
a stream should consider it's buffers to be indicative of state.
 [2012-11-15 16:47 UTC] thuejk at gmail dot com
I have the impression that you did not read my bug report. Your reply does not 
make sense to me. I do say that the current behavior is expected. What I also say 
is that the documentation disagrees.

This bug should be reopened.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 30 00:01:35 2024 UTC