1 .\" $NetBSD: getitimer.2,v 1.28 2011/10/27 16:10:37 christos Exp $
3 .\" Copyright (c) 1983, 1991, 1993
4 .\" The Regents of the University of California. All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in the
13 .\" documentation and/or other materials provided with the distribution.
14 .\" 3. Neither the name of the University nor the names of its contributors
15 .\" may be used to endorse or promote products derived from this software
16 .\" without specific prior written permission.
18 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 .\" @(#)getitimer.2 8.3 (Berkeley) 5/16/95
38 .Nd get/set value of interval timer
44 .Fn getitimer "int which" "struct itimerval *value"
46 .Fn setitimer "int which" "const struct itimerval * restrict value" "struct itimerval * restrict ovalue"
48 The system provides each process with three interval timers,
50 .Ao Pa sys/time.h Ac .
53 call returns the current value for the timer specified in
59 call sets a timer to the specified
61 returning the previous value of the timer if
66 A timer value is defined by the
69 .Bd -literal -offset indent
71 struct timeval it_interval; /* timer interval */
72 struct timeval it_value; /* current value */
78 is non-zero, it indicates the time to the next timer expiration.
81 is non-zero, it specifies a value to be used in reloading
83 when the timer expires.
86 to 0 disables a timer.
89 to 0 causes a timer to be disabled after its next expiration (assuming
95 parameter specifies the type of the timer:
96 .Bl -tag -width "ITIMER_MONOTONIC " -offset indent
98 timer decrements in real time.
99 This timer is affected by
106 delivered when this timer expires.
107 .It Dv ITIMER_VIRTUAL
108 timer decrements in process virtual time.
109 It runs only when the process is executing.
113 is delivered when it expires.
115 timer decrements both in process virtual time and
116 when the system is running on behalf of the process.
117 It is designed to be used by interpreters in statistically profiling
118 the execution of interpreted programs.
125 Because this signal may interrupt in-progress
126 system calls, programs using this timer must be prepared to
127 restart interrupted system calls.
128 .It Dv ITIMER_MONOTONIC
129 timer decrements in monotonic time.
130 This timer is not affected by
137 delivered when this timer expires.
140 .Bl -bullet -offset indent
142 Time values smaller than the resolution of the
143 system clock are rounded up to this resolution
144 (typically 10 milliseconds).
146 The interaction between
152 is unspecified by the specification.
155 If the calls succeed, a value of 0 is returned.
156 If an error occurs, the value \-1 is returned, and a more precise error
157 code is placed in the global variable
160 Both functions may fail if:
165 parameter specified a bad address.
169 parameter was not a known timer type, or the
171 parameter specified a time that was too large
181 The functions conform to
185 revision however marked both as obsolescent,
186 recommending the use of
194 function call appeared in
198 functionality appeared in