tryppoll.c (588B)
1 /* ISC license. */ 2 3 #undef _POSIX_C_SOURCE 4 #undef _XOPEN_SOURCE 5 6 #ifndef _BSD_SOURCE 7 #define _BSD_SOURCE 8 #endif 9 10 #ifndef _GNU_SOURCE 11 #define _GNU_SOURCE 12 #endif 13 14 #ifndef _DEFAULT_SOURCE 15 #define _DEFAULT_SOURCE 16 #endif 17 18 #include <sys/stat.h> 19 #include <fcntl.h> 20 #include <time.h> 21 #include <poll.h> 22 23 int main (void) 24 { 25 struct pollfd x = { .events = POLLIN } ; 26 struct timespec ts = { .tv_sec = 0, .tv_nsec = 10 } ; 27 x.fd = open("src/sysdeps/tryppoll.c", O_RDONLY); 28 if (x.fd < 0) return 111 ; 29 if (ppoll(&x, 1, &ts, 0) < 0) return 1 ; 30 if (x.revents != POLLIN) return 1 ; 31 return 0 ; 32 }