#include <limits.h>
int main()
{
struct itimerspec timesp;
struct timespec times;
if(clock_gettime(CLOCK_REALTIME,×)==-1){
perror("clock_gettime\n");
return 0;
}
timesp.it_value.tv_sec=times.tv_sec;
timesp.it_value.tv_nsec=times.tv_nsec;
timesp.it_internal.tv_sec=2;
timesp.it_iternal.tv_nsec=0;
int timerfd;
if(timerfd=timerfd_creat(CLOCK_REALTIME,0)==-1){
perror("timer_creat\n");
return 0;
}
if(timerfd_settime(timerfd,TFD_TIMER_ABSTIME,×p,NULL)==-1){
perror("timerfd_creat\n");
return 0;
}
while(1){
uint64_t n;
read(timerfd,&n,sizeof(n));
do something in that way
}
return 0;
}
int main()
{
struct itimerspec timesp;
struct timespec times;
if(clock_gettime(CLOCK_REALTIME,×)==-1){
perror("clock_gettime\n");
return 0;
}
timesp.it_value.tv_sec=times.tv_sec;
timesp.it_value.tv_nsec=times.tv_nsec;
timesp.it_internal.tv_sec=2;
timesp.it_iternal.tv_nsec=0;
int timerfd;
if(timerfd=timerfd_creat(CLOCK_REALTIME,0)==-1){
perror("timer_creat\n");
return 0;
}
if(timerfd_settime(timerfd,TFD_TIMER_ABSTIME,×p,NULL)==-1){
perror("timerfd_creat\n");
return 0;
}
while(1){
uint64_t n;
read(timerfd,&n,sizeof(n));
do something in that way
}
return 0;
}