Annotation of embedaddon/php/ext/standard/tests/streams/bug64770.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Bug #64770 stream_select() fails with pipes from proc_open()
! 3: --FILE--
! 4: <?php
! 5:
! 6: $descs = array(
! 7: 0 => array('pipe', 'r'), // stdin
! 8: 1 => array('pipe', 'w'), // stdout
! 9: 2 => array('pipe', 'w'), // strerr
! 10: );
! 11:
! 12: $other_opts = array('suppress_errors' => false, 'binary_pipes' => true);
! 13:
! 14: $cmd = (substr(PHP_OS, 0, 3) == 'WIN') ? 'dir' : 'ls';
! 15: $p = proc_open($cmd, $descs, $pipes, '.', NULL, $other_opts);
! 16:
! 17: if (is_resource($p)) {
! 18: $data = '';
! 19:
! 20: while (1) {
! 21: $w = $e = NULL;
! 22: $n = stream_select($pipes, $w, $e, 300);
! 23:
! 24: if ($n === false) {
! 25: echo "no streams \n";
! 26: break;
! 27: } else if ($n === 0) {
! 28: echo "process timed out\n";
! 29: proc_terminate($p, 9);
! 30: break;
! 31: } else if ($n > 0) {
! 32: $line = fread($pipes[1], 8192);
! 33: if (strlen($line) == 0) {
! 34: /* EOF */
! 35: break;
! 36: }
! 37: $data .= $line;
! 38: }
! 39: }
! 40: var_dump(strlen($data));
! 41:
! 42: $ret = proc_close($p);
! 43: var_dump($ret);
! 44: } else {
! 45: echo "no process\n";
! 46: }
! 47: ?>
! 48: ==DONE==
! 49: --EXPECTF--
! 50: int(%d)
! 51: int(0)
! 52: ==DONE==
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>