p A timer value is defined by the .Fa itimerval structure: d -literal -offset indent struct itimerval { struct timeval it_interval; /* timer interval */ struct timeval it_value; /* current value */ }; .Ed
p If .Fa it_value is non-zero, it indicates the time to the next timer expiration. If .Fa it_interval is non-zero, it specifies a value to be used in reloading .Fa it_value when the timer expires. Setting .Fa it_value to 0 disables a timer. Setting .Fa it_interval to 0 causes a timer to be disabled after its next expiration (assuming .Fa it_value is non-zero).
p The .Fa which parameter specifies the type of the timer: l -tag -width "ITIMER_MONOTONIC " -offset indent t Dv ITIMER_REAL timer decrements in real time. This timer is affected by .Xr adjtime 2 and .Xr settimeofday 2 . A .Dv SIGALRM signal is delivered when this timer expires. t Dv ITIMER_VIRTUAL timer decrements in process virtual time. It runs only when the process is executing. A .Dv SIGVTALRM signal is delivered when it expires. t Dv ITIMER_PROF timer decrements both in process virtual time and when the system is running on behalf of the process. It is designed to be used by interpreters in statistically profiling the execution of interpreted programs. Each time the .Dv ITIMER_PROF timer expires, the .Dv SIGPROF signal is delivered. Because this signal may interrupt in-progress system calls, programs using this timer must be prepared to restart interrupted system calls. t Dv ITIMER_MONOTONIC timer decrements in monotonic time. This timer is not affected by .Xr adjtime 2 and .Xr settimeofday 2 . A .Dv SIGALRM signal is delivered when this timer expires. .El Note that: l -bullet -offset indent t Time values smaller than the resolution of the system clock are rounded up to this resolution (typically 10 milliseconds). t The interaction between .Fn setitimer and .Xr alarm 3 or .Xr sleep 3 is unspecified by the specification. .El .Sh RETURN VALUES If the calls succeed, a value of 0 is returned. If an error occurs, the value -1 is returned, and a more precise error code is placed in the global variable .Va errno . .Sh ERRORS Both functions may fail if: l -tag -width Er t Bq Er EFAULT The .Fa value parameter specified a bad address. t Bq Er EINVAL The .Fa which parameter was not a known timer type, or the .Fa value parameter specified a time that was too large to be handled. .El .Sh SEE ALSO .Xr gettimeofday 2 , .Xr select 2 , .Xr sigaction 2 , .Xr itimerval 3 , .Xr timeradd 3 .Sh STANDARDS The functions conform to .St -p1003.1-2001 . The later .St -p1003.1-2008 revision however marked both as obsolescent, recommending the use of .Xr timer_gettime 2 and .Xr timer_settime 2 instead. .Sh HISTORY The .Fn getitimer function call appeared in x 4.2 . The .Dv ITIMER_MONOTONIC functionality appeared in .Nx 6.0 .