<div dir="ltr"><div>Thanks!</div><div><br></div>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?<div><br></div><div>(as mentioned earlier, the "no space left" could just as well happen after the file was closed, so I don't mind that much it's not reported on a close())<br>
<div><br><div class="gmail_quote">On Fri, Jul 27, 2012 at 12:29 PM, Orna Agmon Ben-Yehuda <span dir="ltr"><<a href="mailto:ladypine@gmail.com" target="_blank">ladypine@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">My practical answer:<div><br></div><div>I always check fclose() . It happened to me that it returned errors when the file I was trying to close was already closed (which usually meant I had a bug, because I closed one file twice, another never. It also failed with "no space left on device", when it was trying to flush the rest of the data that was on the way to the file.</div>
<div><br></div><div>Orna</div><div> <br><br><div class="gmail_quote"><div><div class="h5">On Thu, Jul 26, <a href="tel:2012" value="+9722012" target="_blank">2012</a> at 11:49 PM, Elazar Leibovich <span dir="ltr"><<a href="mailto:elazarl@gmail.com" target="_blank">elazarl@gmail.com</a>></span> wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr">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)<div>
<br></div><div>What does it mean? If I understand it correctly, recent write can lie about its success.</div>
<div><br></div><div>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.</div>
<div><br></div><div>What's the practical use case, where you care about close() error, but you don't care enough to need an fsync.</div><div><br></div><div>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.</div>
</div>
<br></div></div>_______________________________________________<br>
Linux-il mailing list<br>
<a href="mailto:Linux-il@cs.huji.ac.il" target="_blank">Linux-il@cs.huji.ac.il</a><br>
<a href="http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il" target="_blank">http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il</a><br>
<br></blockquote></div><span class="HOEnZb"><font color="#888888"><br><br clear="all"><div><br></div>-- <br>Orna Agmon Ben-Yehuda.<br><a href="http://ladypine.org" target="_blank">http://ladypine.org</a><br>
</font></span></div></div>
</blockquote></div><br></div></div></div>