php.net |  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 Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: thuejk at gmail dot com
New email:
PHP Version: OS:

 

 [2012-08-02 09:23 UTC] thuejk at gmail dot com
Description:
------------
The documentation for stream_select() says ( 
http://www.php.net/manual/en/function.stream-select.php )

"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:
---------------
<?php

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

my_passthru2();

?>

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".

Patches

Pull Requests

History

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

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: Sun Dec 22 06:01:30 2024 UTC