On Fri, Jul 27, 2012 at 7:06 PM, Oleg Goldshmidt <p...@goldshmidt.org> wrote: > > On Fri, Jul 27, 2012 at 2:52 PM, Elazar Leibovich <elaz...@gmail.com> 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.
This might not really be helpful to know, the file descriptor is left in an unspecified state according to POSIX, see: http://utcc.utoronto.ca/~cks/space/blog/unix/CloseEINTR Baruch _______________________________________________ Linux-il mailing list Linux-il@cs.huji.ac.il http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il