Date: Wed, 19 Jun 2013 16:12:38 GMT From: John Baldwin <jhb@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 229959 for review Message-ID: <201306191612.r5JGCcgV024738@skunkworks.freebsd.org>
index | next in thread | raw e-mail
http://p4web.freebsd.org/@@229959?ac=10 Change 229959 by jhb@jhb_jhbbsd on 2013/06/19 16:12:00 Cope with Perl's misbehavior. The PERL_CORE hack isn't really suitable though and I should replace that by adding a fdisown(). Affected files ... .. //depot/projects/stdio_file/include/stdio.h#3 edit .. //depot/projects/stdio_file/lib/libc/stdio/Makefile.inc#2 edit .. //depot/projects/stdio_file/lib/libc/stdio/Symbol.map#3 edit .. //depot/projects/stdio_file/lib/libc/stdio/fclose.c#3 edit Differences ... ==== //depot/projects/stdio_file/include/stdio.h#3 (text+ko) ==== @@ -144,7 +144,10 @@ int _fl_count; /* recursive lock count */ int _orientation; /* orientation for fwide() */ __mbstate_t _mbstate; /* multibyte conversion state */ +/* XXX: PERL_CORE is a temporary hack. */ +#if defined(STDIO_INTERNALS) || defined(PERL_CORE) int _file; /* fileno, if Unix descriptor, else -1 */ +#endif }; #ifndef _STDFILE_DECLARED #define _STDFILE_DECLARED ==== //depot/projects/stdio_file/lib/libc/stdio/Makefile.inc#2 (text+ko) ==== @@ -4,6 +4,8 @@ # stdio sources .PATH: ${.CURDIR}/stdio +CFLAGS+= -DSTDIO_INTERNALS + SRCS+= _flock_stub.c asprintf.c clrerr.c dprintf.c \ fclose.c fcloseall.c fdopen.c \ feof.c ferror.c fflush.c fgetc.c fgetln.c fgetpos.c fgets.c fgetwc.c \ ==== //depot/projects/stdio_file/lib/libc/stdio/Symbol.map#3 (text) ==== @@ -8,7 +8,6 @@ funlockfile; asprintf; clearerr; - fclose; fcloseall; feof; ferror; @@ -115,6 +114,7 @@ }; FBSD_1.3 { + fclose; fdopen; fopen; freopen; ==== //depot/projects/stdio_file/lib/libc/stdio/fclose.c#3 (text+ko) ==== @@ -84,3 +84,20 @@ FUNLOCKFILE(fp); return (r); } + +int +fclose_ofile(FILE *fp) +{ + + /* + * Older versions of Perl used to set _file to -1 directly + * to prevent the underlying fd from being closed. Detect + * this by looking for a mismatch between _ofile and _file + * and force _file to -1 if _ofile is -1. + */ + if (fp->_ofile != fp->_file) + fp->_file = fp->_ofile; + return (fclose(fp)); +} + +__sym_compat(fclose, fclose_ofile, FBSD_1.0);help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201306191612.r5JGCcgV024738>
