summaryrefslogtreecommitdiff
path: root/ext/standard/tests/streams/bug60602.phpt
blob: 396695f77287460291cda6c664d5e7608215643e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
--TEST--
Bug #60602 proc_open() modifies environment if it contains arrays
--FILE--
<?php

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

$environment = array('test' => array(1, 2, 3));

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

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);
	var_dump(is_array($environment['test']));
} else {
	echo "no process\n";
}
?>
--EXPECTF--
Warning: Array to string conversion in %s on line %d
int(%d)
int(0)
bool(true)