title: What does closing an invalid file descriptor do?
body: <p>I have some legacy code that does this all over the place:</p>
  
  <pre><code>int fd; // open a file 
  
  if(fd == -1)
  {
      close(fd);
  }
  </code></pre>
  
  <p>This looks very wrong to me.</p>
  
  <p>Is closing an invalid file descriptor valid?</p>