File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / standard / tests / streams / bug64770.phpt
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Mon Jul 22 01:32:09 2013 UTC (11 years, 3 months ago) by misho
Branches: php, MAIN
CVS tags: v5_4_29p0, v5_4_29, v5_4_20p0, v5_4_20, v5_4_17, HEAD
5.4.17

--TEST--
Bug #64770 stream_select() fails with pipes from proc_open() 
--FILE--
<?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);

$cmd = (substr(PHP_OS, 0, 3) == 'WIN') ? 'dir' : 'ls';
$p = proc_open($cmd, $descs, $pipes, '.', NULL, $other_opts);

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

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

		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);
} else {
	echo "no process\n";
}
?>
==DONE==
--EXPECTF--
int(%d)
int(0)
==DONE==

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>