Doc #62723 [NEW]: stream_select returns when there is output, not when state changes
From: thuejk at gmail dot com
Operating system: Linux
PHP version: 5.3.15
Package: Streams related
Bug Type: Documentation Problem
Bug description:stream_select returns when there is output, not when state changes
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".
--
Edit bug report at https://bugs.php.net/bug.php?id=62723&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=62723&r=trysnapshot54
Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=62723&r=trysnapshot53
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=62723&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=62723&r=fixed
Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=62723&r=needdocs
Fixed in release: https://bugs.php.net/fix.php?id=62723&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=62723&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=62723&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=62723&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=62723&r=support
Expected behavior: https://bugs.php.net/fix.php?id=62723&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=62723&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=62723&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=62723&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=62723&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=62723&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=62723&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=62723&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=62723&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=62723&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=62723&r=mysqlcfg
Thread (3 messages)
- thuejk at gmail dot com