]> granicus.if.org Git - php/commitdiff
properly set the pipe blocking option
authorAnatol Belski <ab@php.net>
Tue, 30 Jun 2015 15:21:21 +0000 (17:21 +0200)
committerAnatol Belski <ab@php.net>
Thu, 2 Jul 2015 12:22:57 +0000 (14:22 +0200)
ext/standard/php_fopen_wrapper.c
ext/standard/proc_open.c

index c3bd4b0048ec25a7799fca1e5413b272e9da0a71..89e4a81c3598cf245ab1eb5097242512b8c4503f 100644 (file)
@@ -400,17 +400,19 @@ php_stream * php_stream_url_wrap_php(php_stream_wrapper *wrapper, const char *pa
                if (stream == NULL) {
                        close(fd);
                }
+       }
+
 #ifdef PHP_WIN32
                {
-                       zval *blocking_pipes = php_stream_context_get_option(context, "pipe", "blocking");
-                       if (blocking_pipes) {
-                               convert_to_long(blocking_pipes);
-                               php_stream_set_option(stream, PHP_STREAM_OPTION_PIPE_BLOCKING, Z_LVAL_P(blocking_pipes), NULL);
+                       if (stream && context) {
+                               zval *blocking_pipes = php_stream_context_get_option(context, "pipe", "blocking");
+                               if (blocking_pipes) {
+                                       convert_to_long(blocking_pipes);
+                                       php_stream_set_option(stream, PHP_STREAM_OPTION_PIPE_BLOCKING, Z_LVAL_P(blocking_pipes), NULL);
+                               }
                        }
                }
 #endif
-       }
-
        return stream;
 }
 /* }}} */
index cee4728a545bb99b905ffcf7ddf712d7a4b9874a..447cbbcc6ee97cfd4538418242dec803a3e3e7d4 100644 (file)
@@ -546,7 +546,6 @@ PHP_FUNCTION(proc_open)
                        }
 
 #ifdef PHP_WIN32
-                       php_stream_set_option(stream, PHP_STREAM_OPTION_PIPE_BLOCKING, blocking_pipes, NULL);
                        descriptors[ndesc].childend = dup_fd_as_handle((int)fd);
                        if (descriptors[ndesc].childend == NULL) {
                                php_error_docref(NULL, E_WARNING, "unable to dup File-Handle for descriptor %d", nindex);
@@ -941,6 +940,7 @@ PHP_FUNCTION(proc_open)
 #ifdef PHP_WIN32
                                stream = php_stream_fopen_from_fd(_open_osfhandle((zend_intptr_t)descriptors[i].parentend,
                                                        descriptors[i].mode_flags), mode_string, NULL);
+                               php_stream_set_option(stream, PHP_STREAM_OPTION_PIPE_BLOCKING, blocking_pipes, NULL);
 #else
                                stream = php_stream_fopen_from_fd(descriptors[i].parentend, mode_string, NULL);
 # if defined(F_SETFD) && defined(FD_CLOEXEC)