Created
October 11, 2016 13:50
-
-
Save lukecampbell/ec454aa24176fd53cf0402491038a53c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <poll.h> | |
#include <stdio.h> | |
#include <sys/time.h> | |
#define SECONDS_TO_MICRO 1000000 | |
int main(int argc, char *argv[]) | |
{ | |
struct timeval before, after; | |
int rc; | |
size_t us; | |
gettimeofday(&before, NULL); | |
rc = poll(NULL, 0, 500); /* Sleep 500 ms */ | |
gettimeofday(&after, NULL); | |
us = (after.tv_sec - before.tv_sec) * SECONDS_TO_MICRO + (after.tv_usec - before.tv_usec); | |
if(us < 400000) { | |
printf("poll() is broken\n"); | |
return 1; | |
} | |
printf("poll() works\n"); | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment