Set the expiration time for a timer
#include <time.h> int timer_settime( timer_t timerid, int flags, const struct itimerspec * value, struct itimerspec * ovalue );
- A timer_t object that holds a timer ID, as set by timer_create() .
- The type of timer to arm if you aren't disarming the timer.
The valid bits include:
TIMER_ABSTIME — the it_value
represents an absolute expiration date in seconds and nanoseconds from
1970. If the date specified has already passed, the function
succeeds and the expiration notice is made.
If you don't set this bit, the it_value represents a relative expiration period that's offset from the current system time by the specified number of seconds and nanoseconds.
- TIMER_ABSTIME — the it_value represents an absolute expiration date in seconds and nanoseconds from 1970. If the date specified has already passed, the function succeeds and the expiration notice is made.
- A pointer to a itimerspec structure that specifies the value that you want to set for the timer's time until expiry. For more information, see timer_gettime() .
- NULL, or a pointer to a itimerspec structure that the function fills in with the timer's former time until expiry.
Use the -l c option to qcc to link against this library. This library is usually included automatically.
The timer_settime() function sets the expiration time of the timer specified by timerid from the it_value member of the value argument. If the it_value structure member of value is zero, then the timer is disarmed.
The timer_settime() function rounds up time values that are between two consecutive nonnegative integer multiples of the resolution of the specified timer to the larger multiple of the resolution.
If the it_interval member of value is nonzero, then it specifies a repeat rate that is added to the timer once the it_value period has expired. Subsequently, the timer is automatically rearmed, causing it to become continuous with a period of it_interval.
If the ovalue parameter isn't NULL, then on return from this function it contains a value representing the previous amount of time left before the timer was to have expired, or zero if the timer was disarmed. The previous interval timer period is also stored in the it_interval member.
The timerid is local to the calling process, and must have been created using timer_create().
- An error occurred (errno is set).
- A fault occurred trying to access the buffers provided.
- The timer timerid isn't attached to the calling process or the number of nanoseconds specified by the tv_nsec member of one of the timespec structures in the itimerspec structure pointed to by value is less than zero or greater than or equal to 1000 million.
See timer_create() .