From: Sascha Schumann Date: Tue, 13 May 2003 23:44:35 +0000 (+0000) Subject: Supply STDIN/OUT/ERR_FILENO directly, instead of opening them through X-Git-Tag: php-4.3.2RC3~28 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4066bd0a1787fb06e81b6c3202dd120b37dcf063;p=php Supply STDIN/OUT/ERR_FILENO directly, instead of opening them through stdio's fdopen. --- diff --git a/ext/standard/php_fopen_wrapper.c b/ext/standard/php_fopen_wrapper.c index d361a1791d..87457e60e5 100644 --- a/ext/standard/php_fopen_wrapper.c +++ b/ext/standard/php_fopen_wrapper.c @@ -123,8 +123,7 @@ php_stream_ops php_stream_input_ops = { php_stream * php_stream_url_wrap_php(php_stream_wrapper *wrapper, char *path, char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC) { - FILE * fp = NULL; - php_stream * stream = NULL; + int fd = -1; if (!strncasecmp(path, "php://", 6)) path += 6; @@ -138,19 +137,17 @@ php_stream * php_stream_url_wrap_php(php_stream_wrapper *wrapper, char *path, ch } if (!strcasecmp(path, "stdin")) { - fp = fdopen(dup(STDIN_FILENO), mode); + fd = STDIN_FILENO; } else if (!strcasecmp(path, "stdout")) { - fp = fdopen(dup(STDOUT_FILENO), mode); + fd = STDOUT_FILENO; } else if (!strcasecmp(path, "stderr")) { - fp = fdopen(dup(STDERR_FILENO), mode); + fd = STDERR_FILENO; } - if (fp) { - stream = php_stream_fopen_from_file(fp, mode); - if (stream == NULL) - fclose(fp); + if (fd != -1) { + return php_stream_fopen_from_fd(fd, mode, NULL); } - return stream; + return NULL; } static php_stream_wrapper_ops php_stdio_wops = {