php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #64770 stream_select() fails with pipes from proc_open()
Submitted: 2013-05-03 11:02 UTC Modified: 2013-05-03 11:03 UTC
From: ab@php.net Assigned: ab (profile)
Status: Closed Package: Streams related
PHP Version: 5.5Git-2013-05-03 (Git) OS: Windows x64
Private report: No CVE-ID: None
 [2013-05-03 11:02 UTC] ab@php.net
Description:
------------
When proc_open() delivers the pipes for a process, an attempt to stream_select on them fails. However using stream_get_contents() on the same readable pipes (like stdout) works fine. This bug currently prevents the phpt test suite from running on windows x64.

Test script:
---------------
<?php

$descs = array(
	0 => array('pipe', 'r'), // stdin
	1 => array('pipe', 'w'), // stdout
	2 => array('pipe', 'w'), // strerr
);

$other_opts = array('suppress_errors' => false, 'binary_pipes' => true);

$p = proc_open('dir', $descs, $pipes, '.', NULL, $other_opts);
var_dump($p);

if (is_resource($p)) {
	$data = '';

	while (1) {	
		$n = stream_select($pipes, $w = NULL, $e = NULL, 300);
		var_dump($n);

		if ($n === false) {
			echo "no streams \n";
			break;
		} else if ($n === 0) {
			echo "process timed out\n";
			proc_terminate($p, 9);
			break;
		} else if ($n > 0) {
			$line = fread($pipes[1], 8192);
			if (strlen($line) == 0) {
				/* EOF */
				break;
			}
			$data .= $line;
		}
	}
	var_dump(strlen($data));

	$ret = proc_close($p);
	var_dump($ret);
}
?>
==DONE==


Expected result:
----------------
resource(7) of type (process)
int(5)
int(42)
int(0)
==DONE==

Actual result:
--------------
resource(7) of type (process)

Warning: stream_select(): unable to select [2]: No such file or directory (max_fd=5) in C:\php-sdk\php55\vc11\x64\php-src\stream_select_0.php on line 18
bool(false)
no streams
int(0)
int(255)
==DONE==

Patches

bug64770.phpt (last revision 2013-11-14 10:14 UTC by s_kinon at yahoo dot com)

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-05-03 11:03 UTC] ab@php.net
This might also be related to bug #63922 or bug #44908 or both.
 [2013-05-03 11:03 UTC] ab@php.net
-Assigned To: +Assigned To: ab
 [2013-05-03 15:06 UTC] ab@php.net
Automatic comment on behalf of ab
Revision: http://git.php.net/?p=php-src.git;a=commit;h=b1ea0b7a7a580f074d889f9ff7a46566917088f2
Log: Fixed bug #64770 stream_select() fails with pipes
 [2013-05-03 15:06 UTC] ab@php.net
-Status: Assigned +Status: Closed
 [2014-10-07 23:19 UTC] stas@php.net
Automatic comment on behalf of ab
Revision: http://git.php.net/?p=php-src-security.git;a=commit;h=b1ea0b7a7a580f074d889f9ff7a46566917088f2
Log: Fixed bug #64770 stream_select() fails with pipes
 [2014-10-07 23:30 UTC] stas@php.net
Automatic comment on behalf of ab
Revision: http://git.php.net/?p=php-src-security.git;a=commit;h=b1ea0b7a7a580f074d889f9ff7a46566917088f2
Log: Fixed bug #64770 stream_select() fails with pipes
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 30 14:01:28 2024 UTC