only get the file pointer if fd is actually valid.