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;
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;
}
#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)
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);
/* skip the sanity check; fstat doesn't appear to work on
* UNC paths */
if (!IS_UNC_PATH(filename, strlen(filename)))
-#endif
+#endif
goto err;
}