php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72853 stream_set_blocking doesn't work
Submitted: 2016-08-16 09:35 UTC Modified: 2016-08-17 08:25 UTC
From: giacovelli2k at gmail dot com Assigned:
Status: Closed Package: Streams related
PHP Version: 7.0.9 OS: ubuntu 16.04.2
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: giacovelli2k at gmail dot com
New email:
PHP Version: OS:

 

 [2016-08-16 09:35 UTC] 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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-08-17 08:25 UTC] laruence@php.net
-Status: Open +Status: Analyzed
 [2016-08-17 08:25 UTC] 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-17 09:15 UTC] laruence@php.net
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)
 [2016-08-17 09:15 UTC] laruence@php.net
-Status: Analyzed +Status: Closed
 [2016-10-17 10:09 UTC] bwoebi@php.net
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)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Nov 22 17:01:31 2024 UTC