Bug #72853 [Ana->Csd]: stream_set_blocking doesn't work
Edit report at https://bugs.php.net/bug.php?id=72853&edit=1
ID: 72853
Updated by: laruence@php.net
Reported by: giacovelli2k at gmail dot com
Summary: stream_set_blocking doesn't work
-Status: Analyzed
+Status: Closed
Type: Bug
Package: Streams related
Operating System: ubuntu 16.04.2
PHP Version: 7.0.9
Block user comment: N
Private report: N
New Comment:
Automatic comment on behalf of laruence@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=abe00908afa2b7227cfd601ee948ff3b57c27eb7
Log: Fixed bug #72853 (stream_set_blocking doesn't work)
Previous Comments:
------------------------------------------------------------------------
[2016-08-17 08:25:02] laruence@php.net
the real problem is , the fd is actually has been set to non-blocking mode, but get_meta_data
returns "blocked -> 1".
and that is because plain_wrapper doesn't implement PHP_STREAM_OPTION_META_DATA_API..
------------------------------------------------------------------------
[2016-08-16 09:35:28] giacovelli2k at gmail dot com
Description:
------------
stream_set_blocking() simply doesn't work and block fgets function for retrieve data from
stream
Test script:
---------------
<?php
$descriptorspec = array(
0 => array("pipe", "r"),
1 => array("pipe", "w")
);
$cwd = '/tmp';
$env = array();
$process = proc_open('uname -a', $descriptorspec, $pipes, $cwd, $env);
if(stream_set_blocking($pipes[1], false)){
echo "Success";
}else{
echo "Failed";
}
var_dump(stream_get_meta_data($pipes[1]));
$out = fgets ($pipes[1], 1024);
echo $out;
if(!$out){
die("ERROR");
}
?>
Expected result:
----------------
Success
array(7) {
["timed_out"]=> bool(false)
["blocked"]=> bool(false)
["eof"]=> bool(false)
["stream_type"]=> string(5) "STDIO"
["mode"]=> string(1) "r"
["unread_bytes"]=> int(0)
["seekable"]=> bool(false)
}
Linux riot 4.4.0-31-generic #50-Ubuntu SMP Wed Jul 13 00:07:12 UTC 2016 x86_64 x86_64 x86_64
GNU/Linux
Actual result:
--------------
Success
array(7) {
["timed_out"]=> bool(false)
["blocked"]=> bool(true)
["eof"]=> bool(false)
["stream_type"]=> string(5) "STDIO"
["mode"]=> string(1) "r"
["unread_bytes"]=> int(0)
["seekable"]=> bool(false)
}
ERROR
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=72853&edit=1
Thread (3 messages)