1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
#include <errno.h> #include <stdio.h> #include <sys/select.h> volatile unsigned int variable = 0; int main() { struct timeval tv; int val; for (;;) { tv.tv_sec = 1; tv.tv_usec = 0; do { val = select(0, NULL, NULL, NULL, &tv); } while (val != 0 && errno == EINTR); printf("Variable = %u\n", ++variable); } }