On Fri, Jul 27, 2012 at 2:52 PM, Elazar Leibovich <[email protected]> wrote:

> 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?

Not only for catching your bugs. If fclose(3) returns an error any
further access  to the descriptor, including another call to
fclose(3), results in undefined behaviour, and I'd regard that as the
scariest thing that can happen to a program.

There is another reason to check the status: a call to close() might
have been interrupted by a signal. In some cases the call may be
resumed after the signal is handled, in some cases the call returns an
error status (errno=EINTR usually?). I suppose you want to know
whether the descriptor was or was not closed.

-- 
Oleg Goldshmidt | [email protected]

_______________________________________________
Linux-il mailing list
[email protected]
http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il

Reply via email to