1 .\" $NetBSD: getrusage.2,v 1.18 2004/05/13 10:20:58 wiz Exp $
3 .\" Copyright (c) 1985, 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 .\" @(#)getrusage.2 8.1 (Berkeley) 6/4/93
37 .Nd get information about resource utilization
42 .Fd #define RUSAGE_SELF 0
43 .Fd #define RUSAGE_CHILDREN \-1
45 .Fn getrusage "int who" "struct rusage *rusage"
48 returns information describing the resources used by the current
49 process, or all its terminated child processes.
58 points will be filled in with
59 the following structure:
62 struct timeval ru_utime; /* user time used */
63 struct timeval ru_stime; /* system time used */
64 long ru_maxrss; /* max resident set size */
65 long ru_ixrss; /* integral shared text memory size */
66 long ru_idrss; /* integral unshared data size */
67 long ru_isrss; /* integral unshared stack size */
68 long ru_minflt; /* page reclaims */
69 long ru_majflt; /* page faults */
70 long ru_nswap; /* swaps */
71 long ru_inblock; /* block input operations */
72 long ru_oublock; /* block output operations */
73 long ru_msgsnd; /* messages sent */
74 long ru_msgrcv; /* messages received */
75 long ru_nsignals; /* signals received */
76 long ru_nvcsw; /* voluntary context switches */
77 long ru_nivcsw; /* involuntary context switches */
81 The fields are interpreted as follows:
82 .Bl -tag -width ru_minfltaa
84 the total amount of time spent executing in user mode.
86 the total amount of time spent in the system executing on behalf
89 the maximum resident set size used (in kilobytes).
91 an \*(lqintegral\*(rq value indicating the amount of memory used
93 that was also shared among other processes.
94 This value is expressed
95 in units of kilobytes * ticks-of-execution.
97 an integral value of the amount of unshared memory residing in the
98 data segment of a process (expressed in units of
99 kilobytes * ticks-of-execution).
101 an integral value of the amount of unshared memory residing in the
102 stack segment of a process (expressed in units of
103 kilobytes * ticks-of-execution).
105 the number of page faults serviced without any I/O activity; here
106 I/O activity is avoided by \*(lqreclaiming\*(rq a page frame from
107 the list of pages awaiting reallocation.
109 the number of page faults serviced that required I/O activity.
111 the number of times a process was \*(lqswapped\*(rq out of main
114 the number of times the file system had to perform input.
116 the number of times the file system had to perform output.
118 the number of IPC messages sent.
120 the number of IPC messages received.
122 the number of signals delivered.
124 the number of times a context switch resulted due to a process
125 voluntarily giving up the processor before its time slice was
126 completed (usually to await availability of a resource).
128 the number of times a context switch resulted due to a higher
129 priority process becoming runnable or because the current process
130 exceeded its time slice.
137 account only for real
138 I/O; data supplied by the caching mechanism is charged only
139 to the first process to read or write the data.
142 returns \-1 on error.
143 The possible errors are:
148 parameter is not a valid value.
150 The address specified by the
152 parameter is not in a valid part of the process address space.
160 function call appeared in
163 There is no way to obtain information about a child process
164 that has not yet terminated.