Hi,
I am trying to use a timer and SIGALRM to call some functions
time-dependent. I set sa_flags to SA_RESTART to automatically restart
interrupted system calls (see code below). But if my program is
blocked inside select when the timer fires, select aborts with
errno == -EINTR instead of being restarted. What ist wrong?
Thanks for any hint,
Dirk
--------- code -----------------
struct sigaction sa_old;
void client_tmsinit(void)
{
struct sigaction sa;
sa.sa_handler = do_timer;
sigemptyset(&sa.sa_mask);
sa.sa_flags = SA_RESTART;
sigaction(SIGALRM, &sa, &tms.sa_old);
void prepare_next_alarm(unsigned long expires /* ms */)Quote:}
{
struct itimerval val;
int n;
if (tms.used_timer) {
val.it_interval.tv_usec = 0;
val.it_interval.tv_sec = 0;
val.it_value.tv_usec = (expires % 1000) * 1000;
val.it_value.tv_sec = expires/1000;
n = setitimer (ITIMER_REAL, &val, NULL);
if (n<0) {
perror("set_itimer");
}
}
Quote:}