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

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

Elazar Leibovich elazarl at gmail.com
Thu Jul 26 23:49:32 IDT 2012


I was always intrigued by this unix tidbit, closing a file can return an
error. In practice, it is rarely checked (as far as I've seen)

What does it mean? If I understand it correctly, recent write can lie about
its success.

But when do you really need it? If you have a piece of information you want
to make sure it hits the disk, the reasonable thing to do is to fsync the
file, and check the error of the fsync. If you don't care about it that
much, then don't check the error, you don't have much to do even if it
failed. It seems to me that one can make close return void, and point the
one who wishes to make sure data hit the disk to fsync.

What's the practical use case, where you care about close() error, but you
don't care enough to need an fsync.

Another question is, why let write lie about its success, what does it gain
you? Let close return void, and force write never to defer its error
reporting.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.cs.huji.ac.il/pipermail/linux-il/attachments/20120726/349fcd97/attachment.html>


More information about the Linux-il mailing list