title: What to do if a posix close call fails?
body: <p>On my system (Ubuntu Linux, glibc), man page of a <code>close</code> call specifies several error return values it can return. It also says</p>
  
  <blockquote>
    <p>Not  checking the return value of close() is a common but nevertheless serious programming error.</p>
  </blockquote>
  
  <p>and at the same time</p>
  
  <blockquote>
    <p>Note that the return value should only  be  used  for  diagnostics. In particular close()  should  not be retried after an EINTR since this may cause a reused descriptor from another thread to be closed.</p>
  </blockquote>
  
  <p>So I am not allowed to ignore the return value nor to retry the call.</p>
  
  <p>Given that, how shall I handle the <code>close()</code> call failure?</p>
  
  <p>If the error happened when I was writing something to the file, I am probably supposed to try to write the information somewhere else to avoid the data loss. </p>
  
  <p>If I was only reading the file, can I just log the failure and continue the program pretending nothing happened? Are there any caveats, leak of file descriptors or whatever else?</p>