From: ab
Operating system: Windows x64
PHP version: 5.5Git-2013-05-03 (Git)
Package: Streams related
Bug Type: Bug
Bug description:stream_select() fails with pipes from proc_open()
Description:
------------
When proc_open() delivers the pipes for a process, an attempt to
stream_select on them fails. However using stream_get_contents() on the
same readable pipes (like stdout) works fine. This bug currently prevents
the phpt test suite from running on windows x64.
Test script:
---------------
<?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);
$p = proc_open('dir', $descs, $pipes, '.', NULL, $other_opts);
var_dump($p);
if (is_resource($p)) {
$data = '';
while (1) {
$n = stream_select($pipes, $w = NULL, $e = NULL, 300);
var_dump($n);
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);
}
?>
==DONE==
Expected result:
----------------
resource(7) of type (process)
int(5)
int(42)
int(0)
==DONE==
Actual result:
--------------
resource(7) of type (process)
Warning: stream_select(): unable to select [2]: No such file or directory
(max_fd=5) in C:\php-sdk\php55\vc11\x64\php-src\stream_select_0.php on line
18
bool(false)
no streams
int(0)
int(255)
==DONE==
--
Edit bug report at https://bugs.php.net/bug.php?id=64770&edit=1
--
Try a snapshot (PHP 5.4):
https://bugs.php.net/fix.php?id=64770&r=trysnapshot54
Try a snapshot (PHP 5.3):
https://bugs.php.net/fix.php?id=64770&r=trysnapshot53
Try a snapshot (trunk):
https://bugs.php.net/fix.php?id=64770&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=64770&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=64770&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=64770&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=64770&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=64770&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=64770&r=support
Expected behavior: https://bugs.php.net/fix.php?id=64770&r=notwrong
Not enough info:
https://bugs.php.net/fix.php?id=64770&r=notenoughinfo
Submitted twice:
https://bugs.php.net/fix.php?id=64770&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=64770&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=64770&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=64770&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=64770&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=64770&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=64770&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=64770&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=64770&r=mysqlcfg