]> granicus.if.org Git - php/commitdiff
MFH fix for bug #21077.
authorWez Furlong <wez@php.net>
Thu, 19 Dec 2002 20:34:34 +0000 (20:34 +0000)
committerWez Furlong <wez@php.net>
Thu, 19 Dec 2002 20:34:34 +0000 (20:34 +0000)
(proc_open problems with BSD)

ext/standard/exec.c
main/streams.c

index fd5076297bb7e1dd1dd8f5e61787df461b1b66a3..7313ce6e57cd34ecb498480e10cc3ff722201f2f 100644 (file)
@@ -976,7 +976,7 @@ PHP_FUNCTION(proc_open)
                                fp = fdopen(descriptors[i].parentend, mode_string);
 #endif
                                if (fp) {
-                                       stream = php_stream_fopen_from_pipe(fp, mode_string);
+                                       stream = php_stream_fopen_from_file(fp, mode_string);
                                        if (stream) {
                                                zval *retfp;
 
index 72df26ea16fb56350a53fbd501784ab9d35b0333..abfdd52255fe7f591fa1bd23aaf28b76bab200a2 100755 (executable)
@@ -1298,6 +1298,7 @@ PHPAPI php_stream *_php_stream_fopen_tmpfile(int dummy STREAMS_DC TSRMLS_DC)
 PHPAPI php_stream *_php_stream_fopen_from_file(FILE *file, const char *mode STREAMS_DC TSRMLS_DC)
 {
        php_stdio_stream_data *self;
+       php_stream *stream;
        
        self = emalloc_rel_orig(sizeof(*self));
        self->file = file;
@@ -1314,7 +1315,13 @@ PHPAPI php_stream *_php_stream_fopen_from_file(FILE *file, const char *mode STRE
        }
 #endif
        
-       return php_stream_alloc_rel(&php_stream_stdio_ops, self, 0, mode);
+       stream = php_stream_alloc_rel(&php_stream_stdio_ops, self, 0, mode);
+
+       if (stream && self->is_pipe) {
+               stream->flags |= PHP_STREAM_FLAG_NO_SEEK;
+       }
+
+       return stream;
 }
 
 PHPAPI php_stream *_php_stream_fopen_from_pipe(FILE *file, const char *mode STREAMS_DC TSRMLS_DC)
@@ -1403,10 +1410,11 @@ static int php_stdiop_close(php_stream *stream, int close_handle TSRMLS_DC)
                                        ret = WEXITSTATUS(ret);
                                }
 #endif
-
                        } else {
                                ret = fclose(data->file);
                        }
+               } else {
+                       return 0;/* everything should be closed already -> success*/
                }
                if (data->temp_file_name) {
                        unlink(data->temp_file_name);
@@ -1786,7 +1794,7 @@ PHPAPI php_stream *_php_stream_fopen(const char *filename, const char *mode, cha
                        /* skip the sanity check; fstat doesn't appear to work on
                         * UNC paths */
                        if (!IS_UNC_PATH(filename, strlen(filename)))
-#endif                 
+#endif
                                goto err;
                }