1timer_settime(2) System Calls Manual timer_settime(2)
2
3
4
6 timer_settime, timer_gettime - arm/disarm and fetch state of POSIX per-
7 process timer
8
10 Real-time library (librt, -lrt)
11
13 #include <time.h>
14
15 int timer_gettime(timer_t timerid, struct itimerspec *curr_value);
16 int timer_settime(timer_t timerid, int flags,
17 const struct itimerspec *restrict new_value,
18 struct itimerspec *_Nullable restrict old_value);
19
20 Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
21
22 timer_settime(), timer_gettime():
23 _POSIX_C_SOURCE >= 199309L
24
26 timer_settime() arms or disarms the timer identified by timerid. The
27 new_value argument is pointer to an itimerspec structure that specifies
28 the new initial value and the new interval for the timer. The itimer‐
29 spec structure is described in itimerspec(3type).
30
31 Each of the substructures of the itimerspec structure is a timespec(3)
32 structure that allows a time value to be specified in seconds and
33 nanoseconds. These time values are measured according to the clock
34 that was specified when the timer was created by timer_create(2).
35
36 If new_value->it_value specifies a nonzero value (i.e., either subfield
37 is nonzero), then timer_settime() arms (starts) the timer, setting it
38 to initially expire at the given time. (If the timer was already
39 armed, then the previous settings are overwritten.) If
40 new_value->it_value specifies a zero value (i.e., both subfields are
41 zero), then the timer is disarmed.
42
43 The new_value->it_interval field specifies the period of the timer, in
44 seconds and nanoseconds. If this field is nonzero, then each time that
45 an armed timer expires, the timer is reloaded from the value specified
46 in new_value->it_interval. If new_value->it_interval specifies a zero
47 value, then the timer expires just once, at the time specified by
48 it_value.
49
50 By default, the initial expiration time specified in
51 new_value->it_value is interpreted relative to the current time on the
52 timer's clock at the time of the call. This can be modified by speci‐
53 fying TIMER_ABSTIME in flags, in which case new_value->it_value is in‐
54 terpreted as an absolute value as measured on the timer's clock; that
55 is, the timer will expire when the clock value reaches the value speci‐
56 fied by new_value->it_value. If the specified absolute time has al‐
57 ready passed, then the timer expires immediately, and the overrun count
58 (see timer_getoverrun(2)) will be set correctly.
59
60 If the value of the CLOCK_REALTIME clock is adjusted while an absolute
61 timer based on that clock is armed, then the expiration of the timer
62 will be appropriately adjusted. Adjustments to the CLOCK_REALTIME
63 clock have no effect on relative timers based on that clock.
64
65 If old_value is not NULL, then it points to a buffer that is used to
66 return the previous interval of the timer (in old_value->it_interval)
67 and the amount of time until the timer would previously have next ex