title: How to check if a given file descriptor stored in a variable is still valid?
body: <p>I have a file descriptor stored in a variable say var. How can I check whether that descriptor is valid at a later stage? </p>
  
  <pre><code>  fdvar1= open(.....);
    fdvar2 = fdvar1;       // Please ignore the bad design
  
    ....
    // lots of loops , conditionals and threads. It can call close(fdvar2) also.  
    ....
  
    if(CheckValid(fdvar1)) // How can I do this check  ?
      write(fdvar1, ....);
  </code></pre>
  
  <p>Now i want to check whether var1 (which still holds the opened descriptor) is still valid.
  Any API's for that ?</p>