I have a file descriptor stored in a variable say var. How can I check whether that descriptor is valid at a later stage?
  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, ....);
Now i want to check whether var1 (which still holds the opened descriptor) is still valid. Any API's for that ?