#include <sys/time.h> int getitimer(int which, struct itimerval *value) int setitimer(int which, const struct itimerval *value, struct itimerval *ovalue);
Setitimer sets a new value for the given interval timer, as given in value, and, if ovalue is not set to NULL , stores the old value for the interval timer in ovalue.
For both functions, the which parameter indicates which of the interval timers they work on; which can have one of the following values:
15 ITIMER_REAL A timer that is decremented in realtime. When it expires, a SIGARLM signal is delivered to the process.
ITIMER_VIRTUAL A timer that is decremented in process user time. When it expires, a SIGVTALRM signal is delivered to the process.
ITIMER_PROF A timer that is decremented in process user+system time. When it expires, a SIGPROF signal is delivered to the process.
The specified timer will first expire after the time specified in the 'it_value' field of the itimerval structure. Similarly, upon retrieval the 'it_value' field will contain the time after which the timer will expire.
If 'it_value' is zero, then the timer is disabled, and the 'it_interval' field is ignored and (upon retrieval) set to zero. Otherwise, 'it_interval' contains the repetition interval after which the timer will repeatedly expire, starting from the moment that the timer expires for the first time according to the 'it_value' value. If 'it_interval' is set to zero, no repetition will occur.
The maximum supported timeout value that setitimer accepts, depends on the clock tick rate of the operating system.
These functions share their real-time timer with alarm (2). Therefore, use of both types of functions in one program yields undefined results.
15 EINVAL Either which is not one of the ITIMER_* constants above, or one of the timeval structures in value contains a bad or too large value.
EFAULT Bad value or ovalue address.