What's the practical use of the error close() returns?

What's the practical use of the error close() returns?

Nadav Har'El nyh at math.technion.ac.il
Fri Jul 27 20:29:18 IDT 2012


On Fri, Jul 27, 2012, Elazar Leibovich wrote about "Re: What's the practical use of the error close() returns?":
> You nailed it! closing a file twice is an error that makes sense to be
> issued at close. So simple, how could I miss it?

Yes, that's a good reason - nice catch. I also didn't think about it.

But note that closing a non-open fd gives an EBADF, which is different
from the EIO errors we've been talking about in this thread.

Also note that an EBADF usually indicates a *logic error* in your
program, i.e., a bug (there's a code path that makes you close a non-open
fd). If you have this bug, you can't really count on the EBADF - because
it's quite possible you'll close another opened fd, not a non-opened
one, and not get any error....

-- 
Nadav Har'El                        |           Friday, Jul 27 2012, 9 Av 5772
nyh at math.technion.ac.il             |-----------------------------------------
Phone +972-523-790466, ICQ 13349191 |Disclaimer: The opinions expressed above
http://nadav.harel.org.il           |are not my own.



More information about the Linux-il mailing list