This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC][BZ #14627] Make linux close errno to EINPROGRESS when interrupted in signal.


On Thu, Dec 05, 2013 at 12:57:36PM -0800, Russ Allbery wrote:
> David Miller <davem@davemloft.net> writes:
> 
> > At one time many years ago there was a path in the kernel that returned
> > an error from close and it broke so many things.  Even emacs crashed.
> 
> > The widespread overwhelming belief is that close() is just going to
> > always succeed, and there is more harm than good from signalling errors
> > at all from that function.
> 
> Indeed, all the C code that I've seen either assumes that failure on
> close() is some sort of write failure and treats it as such, or ignores
> failure entirely.  Having close() return a failure and leave the file
> descriptor open would cause a file descriptor leak in most code I've seen
> and would result in a possibly incorrect diagnosed failure to write to the
> file in all of the rest.
> 
> It's very unclear what a C programmer should do when close() returns
> failure.  POSIX 2008 says that the state of the file descriptor after a
> close failure is undefined, which I assume means that one should just
> retry the close (how many times?), but that relies on the assumption that
> it's safe to close a file descriptor that's already closed and the worst
> that will happen is that you'll get back EBADF.

You missed the beginning of this discussion (which, to be fair, was in
another thread: https://www.sourceware.org/ml/libc-alpha/2013-12/msg00108.html) 
where it was noted that POSIX has fixed this bug:

http://austingroupbugs.net/view.php?id=529

The new requirement is that EINTR means the fd is still open and
EINPROGRESS means the operation was interrupted by a signal but the fd
is no longer valid.

Rich


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]