#include #include #include #include #include #include #include #include int main(int argc, char **argv) { fd_set readfds; int fd, ret; setprogname(argv[0]); if (argc != 2) errx(1, "Usage: %s ", getprogname()); fd = atoi(argv[1]); if (fcntl(fd, F_GETFL) != -1 || errno != EBADF) errx(1, "fd %d is already open", fd); FD_ZERO(&readfds); FD_SET(fd, &readfds); errno = 0; ret = select(fd + 1, &readfds, NULL, NULL, NULL); printf("ret=%d\nerrno=%d %s\n", ret, errno, strerror(errno)); fflush(stdout); return ferror(stdout); }