A simple timer implementation in C

A simple timer implementation in C

#include <stdio.h>
#include <time.h>
#include<signal.h>

#define TIME_INTERVAL 1

static void timer_handler(int sig) 
{
	printf("Time handler\n");
	alarm(TIME_INTERVAL);
}

int main(int argc, char *argv[])
{
	signal(SIGALRM, timer_handler);

	alarm(TIME_INTERVAL);

	while(1){
		/* do nothing */
	};

	return 0;
}

Comments

Popular posts from this blog

Python Receiving and parse JSON Data via UDP protocol

ubus lua client method and event registration code demo/example