Thanks Mats, you pointed me in the right direction.....
This is the code I'm working with now... it's a small test program where I want to get a timer running with an interval of 1,5 seconds... every time when the timer is done I want to print "hello from the timer" to the screen.
First off my declarations:
Then my main function... first off some values for the timer, not sure if this is correct, but I want an interval of 1,5 sec... wasn't sure what to do with start_time struct.
struct itimerspec itset_time;
struct itimerspec start_time;
static void sighandler (int whatever);
I now the code is a bit rough, with the endless loop and all..... not very pretty.
//Init values timer
itset_time.it_interval.tv_nsec = 500;
itset_time.it_interval.tv_sec = 1;
itset_time.it_value.tv_nsec = 0;
itset_time.it_value.tv_sec = 0;
start_time.it_value.tv_nsec = 0;
start_time.it_value.tv_sec = 0;
start_time.it_interval.tv_nsec = 0;
start_time.it_interval.tv_sec = 0;
fdClock = timerfd_create(CLOCK_REALTIME, O_NONBLOCK);
timerfd_settime(fdClock, FD_CLOEXEC, itset_time, start_time);
But I hope it does the trick, I've got the feeling I'm doing something wrong with or the timer or the signal indications, but no idea which it is. Did interrupts on PIC microcontroller, but Linux is new to me. With microcontrollers I have to reset the flag on my own to get the any new interrupt from a timer, same here? or does the OS reset the flag? I have the feeling I'm forgetting the resetting as well.
The sighandler is implemented as follows:
The code compiles, but it doesn't do anything... what's missing?
void sighandler(int whatever)
printf("hello from the timer\n");