Skip to content

Instantly share code, notes, and snippets.

@lukecampbell
Created October 11, 2016 13:50
Show Gist options
  • Save lukecampbell/ec454aa24176fd53cf0402491038a53c to your computer and use it in GitHub Desktop.
Save lukecampbell/ec454aa24176fd53cf0402491038a53c to your computer and use it in GitHub Desktop.
#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