Annotation of embedaddon/php/ext/standard/tests/file/proc_open01.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: proc_open() regression test 1 (proc_open() leak)
3: --FILE--
4: <?php
5: $pipes = array(1, 2, 3);
6: $orig_pipes = $pipes;
7: $php = getenv('TEST_PHP_EXECUTABLE');
8: if ($php === false) {
9: die("no php executable defined");
10: }
11: $proc = proc_open(
12: "$php -n",
13: array(0 => array('pipe', 'r'), 1 => array('pipe', 'w')),
14: $pipes, getcwd(), array(), array('binary_pipes' => true)
15: );
16: if ($proc === false) {
17: print "something went wrong.\n";
18: }
19: var_dump($pipes);
20: stream_set_blocking($pipes[1], FALSE);
21: $test_string = b"yay!\n";
22: fwrite($pipes[0], $test_string);
23: fflush($pipes[0]);
24: fclose($pipes[0]);
25: $cnt = '';
26: $n=0;
27: for ($left = strlen($test_string); $left > 0;) {
28: if (++$n >1000) {
29: print "terminated after 1000 iterations\n";
30: break;
31: }
32: $read_fds = array($pipes[1]);
33: $write_fds = NULL;
34: $exp_fds = NULL;
35: $retval = stream_select($read_fds, $write_fds, $exp_fds, 5);
36: if ($retval === false) {
37: print "select() failed\n";
38: break;
39: }
40: if ($retval === 0) {
41: print "timed out\n";
42: break;
43: }
44: $buf = fread($pipes[1], 1024);
45: $cnt .= $buf;
46: $left -= strlen($buf);
47: }
48: var_dump($cnt);
49: fclose($pipes[1]);
50: proc_close($proc);
51: var_dump($orig_pipes);
52: ?>
53: --EXPECTF--
54: array(2) {
55: [0]=>
56: resource(%d) of type (stream)
57: [1]=>
58: resource(%d) of type (stream)
59: }
60: %unicode|string%(5) "yay!
61: "
62: array(3) {
63: [0]=>
64: int(1)
65: [1]=>
66: int(2)
67: [2]=>
68: int(3)
69: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>