.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved 
.TH "GETITIMER" 3P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
.\" getitimer 
.SH PROLOG
This manual page is part of the POSIX Programmer's Manual.
The Linux implementation of this interface may differ (consult
the corresponding Linux manual page for details of Linux behavior),
or the interface may not be implemented on Linux.
.SH NAME
getitimer, setitimer \- get and set value of interval timer
.SH SYNOPSIS
.LP
\fB#include <sys/time.h>
.br
.sp
int getitimer(int\fP \fIwhich\fP\fB, struct itimerval *\fP\fIvalue\fP\fB);
.br
int setitimer(int\fP \fIwhich\fP\fB, const struct itimerval *restrict\fP
\fIvalue\fP\fB,
.br
\ \ \ \ \ \  struct itimerval *restrict\fP \fIovalue\fP\fB); \fP
\fB
.br
\fP
.SH DESCRIPTION
.LP
The \fIgetitimer\fP() function shall store the current value of the
timer specified by \fIwhich\fP into the structure pointed
to by \fIvalue\fP. The \fIsetitimer\fP() function shall set the timer
specified by \fIwhich\fP to the value specified in the
structure pointed to by \fIvalue\fP, and if \fIovalue\fP is not a
null pointer, store the previous value of the timer in the
structure pointed to by \fIovalue\fP.
.LP
A timer value is defined by the \fBitimerval\fP structure, specified
in \fI<sys/time.h>\fP. If \fIit_value\fP is non-zero, it shall indicate
the time to the next
timer expiration. If \fIit_interval\fP is non-zero, it shall specify
a value to be used in reloading \fIit_value\fP when the
timer expires. Setting \fIit_value\fP to 0 shall disable a timer,
regardless of the value of \fIit_interval\fP. Setting
\fIit_interval\fP to 0 shall disable a timer after its next expiration
(assuming \fIit_value\fP is non-zero).
.LP
Implementations may place limitations on the granularity of timer
values. For each interval timer, if the requested timer value
requires a finer granularity than the implementation supports, the
actual timer value shall be rounded up to the next supported
value.
.LP
An XSI-conforming implementation provides each process with at least
three interval timers, which are indicated by the
\fIwhich\fP argument:
.TP 7
ITIMER_REAL
Decrements in real time. A SIGALRM signal is delivered when this timer
expires.
.TP 7
ITIMER_VIRTUAL
Decrements in process virtual time. It runs only when the process
is executing. A SIGVTALRM signal is delivered when it
expires.
.TP 7
ITIMER_PROF
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 ITIMER_PROF timer expires, the SIGPROF
signal is delivered.
.sp
.LP
The interaction between \fIsetitimer\fP() and any of \fIalarm\fP(),
\fIsleep\fP(), or \fIusleep\fP() is unspecified.
.SH RETURN VALUE
.LP
Upon successful completion, \fIgetitimer\fP() or \fIsetitimer\fP()
shall return 0; otherwise, -1 shall be returned and
\fIerrno\fP set to indicate the error.
.SH ERRORS
.LP
The \fIsetitimer\fP() function shall fail if:
.TP 7
.B EINVAL
The \fIvalue\fP argument is not in canonical form. (In canonical form,
the number of microseconds is a non-negative integer
less than 1000000 and the number of seconds is a non-negative integer.)
.sp
.LP
The \fIgetitimer\fP() and \fIsetitimer\fP() functions may fail if:
.TP 7
.B EINVAL
The \fIwhich\fP argument is not recognized.
.sp
.LP
\fIThe following sections are informative.\fP
.SH EXAMPLES
.LP
None.
.SH APPLICATION USAGE
.LP
None.
.SH RATIONALE
.LP
None.
.SH FUTURE DIRECTIONS
.LP
None.
.SH SEE ALSO
.LP
\fIalarm\fP(), \fIsleep\fP(), \fItimer_getoverrun\fP(), \fIualarm\fP(),
\fIusleep\fP(), the Base Definitions volume of IEEE\ Std\ 1003.1-2001,
\fI<signal.h>\fP, \fI<sys/time.h>\fP
.SH COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
-- Portable Operating System Interface (POSIX), The Open Group Base
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
Electrical and Electronics Engineers, Inc and The Open Group. In the
event of any discrepancy between this version and the original IEEE and
The Open Group Standard, the original IEEE and The Open Group Standard
is the referee document. The original Standard can be obtained online at
http://www.opengroup.org/unix/online.html .
