From owner-p4-projects@FreeBSD.ORG Wed Jun 19 16:12:39 2013 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 60FB9977; Wed, 19 Jun 2013 16:12:39 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 22F26975 for ; Wed, 19 Jun 2013 16:12:39 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from skunkworks.freebsd.org (skunkworks6.freebsd.org [IPv6:2001:1900:2254:2068::682:0]) by mx1.freebsd.org (Postfix) with ESMTP id ED04D1C9C for ; Wed, 19 Jun 2013 16:12:38 +0000 (UTC) Received: from skunkworks.freebsd.org ([127.0.1.74]) by skunkworks.freebsd.org (8.14.7/8.14.7) with ESMTP id r5JGCc3J024741 for ; Wed, 19 Jun 2013 16:12:38 GMT (envelope-from jhb@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.7/8.14.6/Submit) id r5JGCcgV024738 for perforce@freebsd.org; Wed, 19 Jun 2013 16:12:38 GMT (envelope-from jhb@freebsd.org) Date: Wed, 19 Jun 2013 16:12:38 GMT Message-Id: <201306191612.r5JGCcgV024738@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to jhb@freebsd.org using -f From: John Baldwin Subject: PERFORCE change 229959 for review To: Perforce Change Reviews Precedence: bulk X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.14 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 Jun 2013 16:12:39 -0000 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);