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 =
You can use the fcntl() function:
fcntl()
int fd_is_valid(int fd) { return fcntl(fd, F_GETFD) != -1 || errno != EBADF; }