c – How to check if a given file descriptor stored in a variable is still valid?

int is_valid_fd(int fd)
{
    return fcntl(fd, F_GETFL) != -1 || errno != EBADF;
}

Source: c – How to check if a given file descriptor stored in a variable is still valid? – Stack Overflow

c – How to check if a given file descriptor stored in a variable is still valid? was last modified: December 19th, 2022 by Jovan Stosic

Leave a Reply