/*
 * Use of select(2) only as a timer.
 *
 * by Hans Schou 2004.
 */

#include <stdio.h>
#include <sys/types.h>
#include <termios.h>
#include <stdlib.h>

int main( void ) {
	int run = 10;
	int rc;
	struct timeval tv;

	do {
		/* Set 1/10 sec */
		tv = (struct timeval){0,100000};
		/* Call select and wait for time-out */
		rc = select(0, NULL, NULL, NULL, &tv);
		printf("ReturnCode: %d\n", rc);
		if (rc) {
			/* No file handle */
		} else {
			printf("Count down: %d\n", run);
		}
	} while (run--);

	return EXIT_SUCCESS;
}
