From: Wez Furlong Date: Thu, 19 Dec 2002 20:34:34 +0000 (+0000) Subject: MFH fix for bug #21077. X-Git-Tag: php-4.3.0RC4~15 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3748fb07e8b0f526a6c3a90f9bc6181c19605ef9;p=php MFH fix for bug #21077. (proc_open problems with BSD) --- diff --git a/ext/standard/exec.c b/ext/standard/exec.c index fd5076297b..7313ce6e57 100644 --- a/ext/standard/exec.c +++ b/ext/standard/exec.c @@ -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; diff --git a/main/streams.c b/main/streams.c index 72df26ea16..abfdd52255 100755 --- a/main/streams.c +++ b/main/streams.c @@ -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; }