/* Test providing a bad file descriptor to ppoll. */ #include "signal.h" static void handler(int signum) { (void) signum; printf("SIGUSR1\n"); fflush(stdout); } int main(void) { signal(SIGUSR1, handler); sigset_t sigusr1; sigemptyset(&sigusr1); sigaddset(&sigusr1, SIGUSR1); sigprocmask(SIG_BLOCK, &sigusr1, NULL); sigset_t empty; sigemptyset(&empty); int fds[2]; if ( pipe(fds) ) err(1, "pipe"); // Bad file descriptor is supposed to fail with POLLNVAL. close(fds[0]); // Hurd times out instead of a poll error. alarm(1); struct pollfd pfd = { .fd = fds[0], .events = POLLIN }; int ret = ppoll(&pfd, 1, NULL, &empty); if ( ret < 0 ) err(1, "ppoll"); if ( !ret ) { printf("ppoll() == 0\n"); return 0; } printf("0"); if ( pfd.revents & POLLIN ) printf(" | POLLIN"); if ( pfd.revents & POLLOUT ) printf(" | POLLOUT"); if ( pfd.revents & POLLERR ) printf(" | POLLERR"); if ( pfd.revents & POLLHUP ) printf(" | POLLHUP"); if ( pfd.revents & POLLNVAL ) printf(" | POLLNVAL"); printf("\n"); return 0; }