From owner-freebsd-bugs@FreeBSD.ORG Wed Jan 5 11:20:33 2005 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2A5EE16A4DF for ; Wed, 5 Jan 2005 11:20:33 +0000 (GMT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id E4C6343D45 for ; Wed, 5 Jan 2005 11:20:32 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.1/8.13.1) with ESMTP id j05BKW1G020965 for ; Wed, 5 Jan 2005 11:20:32 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.1/8.13.1/Submit) id j05BKWSO020964; Wed, 5 Jan 2005 11:20:32 GMT (envelope-from gnats) Date: Wed, 5 Jan 2005 11:20:32 GMT Message-Id: <200501051120.j05BKWSO020964@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Giorgos Keramidas Subject: Re: bin/75767: WANTED: "fdclose" function in libc X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Giorgos Keramidas List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Jan 2005 11:20:33 -0000 The following reply was made to PR bin/75767; it has been noted by GNATS. From: Giorgos Keramidas To: "Ronald F. Guilmette" Cc: bug-followup@freebsd.org Subject: Re: bin/75767: WANTED: "fdclose" function in libc Date: Wed, 5 Jan 2005 13:18:26 +0200 On 2005-01-04 05:00, "Ronald F. Guilmette" wrote: >In message <20050104003813.GF45341@gothmog.gr>, you wrote: >> I believe there is no easy way to fdclose() a FILE object _and_ do it in >> a way that would satisfy all the potential uses of such a function. > > I didn't request something that would ``satisfy all of the potential uses > of such a function''. > > My goals are not nearly so gradiose, and my need is a very simple one. >> Some of the problems that an implementation would have to face are >> immediate results of the buffered nature of FILE streams: >> >> a) Should any pending writes be flushed out before the FILE object is >> destroyed? > > Please see my PR. I asked for a function that would do everything that > fclose() does _except_ for calling close() on the underlying file. > [...] > Please see my PR. I asked for a function that would do everything that > fclose() does _except_ for calling close() on the underlying file. I *did* see your PR. I also gave it a bit of careful thought. I'm sorry if my response sounded insulting in any way. That was definitely not my intention. I'm just trying to see why the addition of an unportable function to libc would be beneficial for other libc users too. If there is no way this may be useful to others too, it may as well be left as a patch a few select users who depend on it apply on their source trees. >>> Add a new "fdclose" function to libc. This should have the same >>> effects as fclose, except that it should *not* close the underlying >>> UNIX file descriptor. >> You can probably emulate most of the behavior of fdclose() when such a >> need arises with something like this: [snip] > > Actually, since I sent in my PR, I did some more digging in the sources > of libc, and I found a much simpler way to get what I want, at least on > FreeBSD (however this is quite definitely _not_ portable): > > file->_close = NULL; > fclose (file); > > (I would still like to see the above functionality turned into a library > function however.) Which would be non-standard, supported by FreeBSD only, hence unportable to other systems. I really don't see why adding an unportable function to libc would make things better, but don't let my opinion stop you from doing it if you feel it's useful. - Giorgos