Bug #64770 [Asn->Csd]: stream_select() fails with pipes from proc_open()

From: Date: Fri, 03 May 2013 15:06:42 +0000
Subject: Bug #64770 [Asn->Csd]: stream_select() fails with pipes from proc_open()
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-178779@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=64770&edit=1

 ID:                 64770
 Updated by:         ab@php.net
 Reported by:        ab@php.net
 Summary:            stream_select() fails with pipes from proc_open()
-Status:             Assigned
+Status:             Closed
 Type:               Bug
 Package:            Streams related
 Operating System:   Windows x64
 PHP Version:        5.5Git-2013-05-03 (Git)
 Assigned To:        ab
 Block user comment: N
 Private report:     N

 New Comment:

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


Previous Comments:
------------------------------------------------------------------------
[2013-05-03 11:03:52] ab@php.net

This might also be related to bug #63922 or bug #44908 or both.

------------------------------------------------------------------------
[2013-05-03 11:02:20] 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==


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=64770&edit=1


Thread (3 messages)

« previous php.bugs (#178779) next »