#include <sys/timerfd.h>
#include <stdlib.h>
#include <unistd.h>
+#include <fcntl.h>
#include "timer.h"
int install_timer(int value_sec, int value_nsec, int interval_sec, int interval_nsec, void (*_callback)())
{
- if ( value_sec < 0 || interval_sec < 0 )
+ if ( value_sec < 0 || interval_sec < 0 || _callback == 0 )
return -1;
int timer_fd;
t->id=timer_fd;
t->_callback = _callback;
timer_list = g_slist_prepend(timer_list, t);
+
+ int flags = fcntl( timer_fd, F_GETFL, 0 );
+ if( flags != -1 )
+ fcntl( timer_fd, F_SETFL, flags | O_NONBLOCK );
+
return timer_fd;
}