]>
git.ipfire.org Git - thirdparty/util-linux.git/blob - include/timer.h
1 #ifndef UTIL_LINUX_TIMER_H
2 #define UTIL_LINUX_TIMER_H
7 static inline void setup_timer(
8 struct itimerval
*timer
,
9 struct itimerval
*old_timer
,
10 struct sigaction
*old_sa
,
11 void (*timeout_handler
)(int))
15 memset(&sa
, 0, sizeof sa
);
16 sa
.sa_handler
= timeout_handler
;
17 sa
.sa_flags
= SA_RESETHAND
;
18 sigaction(SIGALRM
, &sa
, old_sa
);
20 setitimer(ITIMER_REAL
, timer
, old_timer
);
23 static inline void cancel_timer(
24 struct itimerval
*old_timer
,
25 struct sigaction
*old_sa
)
27 setitimer(ITIMER_REAL
, old_timer
, NULL
);
28 sigaction(SIGALRM
, old_sa
, NULL
);