bin/75767: WANTED: "fdclose" function in libc

Giorgos Keramidas keramida at freebsd.org
Wed Jan 5 03:20:33 PST 2005


The following reply was made to PR bin/75767; it has been noted by GNATS.

From: Giorgos Keramidas <keramida at freebsd.org>
To: "Ronald F. Guilmette" <rfg at monkeys.com>
Cc: bug-followup at 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" <rfg at monkeys.com> wrote:
 >In message <20050104003813.GF45341 at 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
 


More information about the freebsd-bugs mailing list