8 volatile int ticks
= 0;
9 struct itimerval timert
;
10 struct sigaction timer_action
;
12 void handle_vtalrm(int sig
) { ticks
++; }
15 int main(int argc
, char* argv
[])
17 timer_action
.sa_handler
= handle_vtalrm
;
18 sigemptyset(&timer_action
.sa_mask
);
19 timer_action
.sa_flags
= SA_RESTART
;
21 sigaction(SIGVTALRM
, &timer_action
, NULL
);
23 timert
.it_interval
.tv_sec
= timert
.it_value
.tv_sec
= 0;
24 timert
.it_interval
.tv_usec
= timert
.it_value
.tv_usec
= 500;
25 setitimer(ITIMER_VIRTUAL
, &timert
, NULL
);
27 struct timespec ts_initialized
= {0, 1000000};
28 struct timespec
* too_small
= malloc(1);
30 clock_nanosleep(CLOCK_MONOTONIC
, TIMER_ABSTIME
, &ts_initialized
,