diff options
author | Tjerk Meesters <datibbaw@php.net> | 2013-10-10 20:21:14 +0800 |
---|---|---|
committer | Tjerk Meesters <datibbaw@php.net> | 2014-03-03 05:49:52 +0800 |
commit | e73c05b75e9b279acffe2320fd65e6e54cbd0b59 (patch) | |
tree | b0da4b4f622517c968e9f63f8d9152195c7a6980 /ext/standard/tests/streams | |
parent | 362b70a32cd21a1f31c761b594578c45dd064568 (diff) | |
download | php-git-e73c05b75e9b279acffe2320fd65e6e54cbd0b59.tar.gz |
proc_open(): separate environment values that aren't strings
Added a test case
Diffstat (limited to 'ext/standard/tests/streams')
-rw-r--r-- | ext/standard/tests/streams/bug60602.phpt | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/ext/standard/tests/streams/bug60602.phpt b/ext/standard/tests/streams/bug60602.phpt new file mode 100644 index 0000000000..2c08ce87b7 --- /dev/null +++ b/ext/standard/tests/streams/bug60602.phpt @@ -0,0 +1,57 @@ +--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"; +} +?> +==DONE== +--EXPECTF-- +Notice: Array to string conversion in %s on line %d + +Notice: Array to string conversion in %s on line %d +int(%d) +int(0) +bool(true) +==DONE== |