com php-src: Fixed bug #64770 stream_select() fails w ith pipes: NEWS ext/standard/streamsfuncs.c ext/sta ndard/tests/streams/bug64770.phpt
| From: | Anatol Belski | Date: | Fri, 03 May 2013 15:01:33 +0000 |
| Subject: | com php-src: Fixed bug #64770 stream_select() fails w ith pipes: NEWS ext/standard/streamsfuncs.c ext/sta ndard/tests/streams/bug64770.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-72102@lists.php.net to get a copy of this message | ||
Commit: b1ea0b7a7a580f074d889f9ff7a46566917088f2
Author: Anatol Belski <ab@php.net> Fri, 3 May 2013 17:01:33 +0200
Parents: aa448adc8347c072421103d1a92b0a7a75ec873f
Branches: PHP-5.3 PHP-5.4 PHP-5.5 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=b1ea0b7a7a580f074d889f9ff7a46566917088f2
Log:
Fixed bug #64770 stream_select() fails with pipes
returned by proc_open() on Windows x64
Bugs:
https://bugs.php.net/64770
Changed paths:
M NEWS
M ext/standard/streamsfuncs.c
A ext/standard/tests/streams/bug64770..phpt
Diff:
diff --git a/NEWS b/NEWS
index cd865d2..2d831ae 100644
--- a/NEWS
+++ b/NEWS
@@ -11,6 +11,10 @@ PHP NEWS
. Fixed bug #64726 (Segfault when calling fetch_object on a use_result and DB
pointer has closed). (Laruence)
+- Streams:
+ . Fixed bug #64770 (stream_select() fails with pipes returned by proc_open()
+ on Windows x64).. (Anatol)
+
?? ??? 2013, PHP 5.3.25
### ADD ENTRIES ABOVE FOR 5.3.26. 5.3.25 NEWS WILL BE UPDATED BY RM ON MERGE ###
diff --git a/ext/standard/streamsfuncs.c b/ext/standard/streamsfuncs.c
index 27042f6..465d72d 100644
--- a/ext/standard/streamsfuncs.c
+++ b/ext/standard/streamsfuncs.c
@@ -611,7 +611,7 @@ static int stream_array_to_fd_set(zval *stream_array, fd_set *fds, php_socket_t
{
zval **elem;
php_stream *stream;
- php_socket_t this_fd;
+ php_socket_t this_fd = 0;
int cnt = 0;
if (Z_TYPE_P(stream_array) != IS_ARRAY) {
@@ -648,7 +648,7 @@ static int stream_array_from_fd_set(zval *stream_array, fd_set *fds TSRMLS_DC)
zval **elem, **dest_elem;
php_stream *stream;
HashTable *new_hash;
- php_socket_t this_fd;
+ php_socket_t this_fd = 0;
int ret = 0;
if (Z_TYPE_P(stream_array) != IS_ARRAY) {
diff --git a/ext/standard/tests/streams/bug64770.phpt b/ext/standard/tests/streams/bug64770.phpt
new file mode 100644
index 0000000..ae738d8
--- /dev/null
+++ b/ext/standard/tests/streams/bug64770.phpt
@@ -0,0 +1,51 @@
+--TEST--
+Bug #64770 stream_select() fails with pipes from proc_open()
+--FILE--
+<?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);
+
+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);
+} else {
+ echo "no process\n";
+}
+?>
+==DONE==
+--EXPECTF--
+int(%d)
+int(0)
+==DONE==