From owner-freebsd-current@FreeBSD.ORG Thu Mar 20 14:22:05 2014 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id B9265C4C; Thu, 20 Mar 2014 14:22:05 +0000 (UTC) Received: from bigwig.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 8FB7FBA6; Thu, 20 Mar 2014 14:22:05 +0000 (UTC) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 8B14EB918; Thu, 20 Mar 2014 10:22:03 -0400 (EDT) From: John Baldwin To: freebsd-arch@freebsd.org Subject: Re: Hello fdclose Date: Thu, 20 Mar 2014 09:32:02 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.4-CBSD-20130906; KDE/4.5.5; amd64; ; ) References: <20140318213516.GA71491@stack.nl> In-Reply-To: <20140318213516.GA71491@stack.nl> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201403200932.02294.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Thu, 20 Mar 2014 10:22:03 -0400 (EDT) Cc: freebsd-current@freebsd.org, Jilles Tjoelker , Mariusz Zaborski X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 Mar 2014 14:22:05 -0000 On Tuesday, March 18, 2014 5:35:16 pm Jilles Tjoelker wrote: > On Tue, Mar 18, 2014 at 12:23:19AM +0100, Mariusz Zaborski wrote: > > After our previous discuss [1] I prepare fdclosedir(3) function which > > was committed by Pawel (cc'ed) in commit r254499. > > > A while ago I also prepare the fdclose function. Unfortunately, this > > new function is a little bit more tricky then previous one. Can I ask > > you for a review of this patch? > > Does this patch allow perl to stop writing to FILE._file? As pointed out > in > http://lists.freebsd.org/pipermail/freebsd-current/2013-January/039024.html > perlio.c in the perl source contains a function > PerlIOStdio_invalidate_fileno() that should modify a FILE such that > fclose() does not close the file descriptor but still frees all memory > (Perl has already called fflush()). Although using fdclose() could solve > this without touching the internals of FILE, this will make perlio.c > uglier with even more #ifdefs. I hope it does. I want to have some sort of API for Perl to use so it stops (ab)using _file before I move forward with full int _file. > I think that in cases where fdclose() would be used, it is essential > that the file descriptor is never closed. This means that the API needs > to be different so it can report a write error but still return a file > descriptor. One way to do this is to return the file descriptor by > reference. Another is to expect the application to call fileno() and not > return the descriptor from the new function. I would prefer the latter of requiring the application to use fileno(). -- John Baldwin