Initial import, 0.1 + pk 0.2.4-B1
[unix-history] / lib / libc / sys / getrusage.2
CommitLineData
15637ed4
RG
1.\" Copyright (c) 1985, 1991 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\" notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\" notice, this list of conditions and the following disclaimer in the
11.\" documentation and/or other materials provided with the distribution.
12.\" 3. All advertising materials mentioning features or use of this software
13.\" must display the following acknowledgement:
14.\" This product includes software developed by the University of
15.\" California, Berkeley and its contributors.
16.\" 4. Neither the name of the University nor the names of its contributors
17.\" may be used to endorse or promote products derived from this software
18.\" without specific prior written permission.
19.\"
20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE.
31.\"
32.\" @(#)getrusage.2 6.9 (Berkeley) 3/10/91
33.\"
34.Dd March 10, 1991
35.Dt GETRUSAGE 2
36.Os BSD 4
37.Sh NAME
38.Nm getrusage
39.Nd get information about resource utilization
40.Sh SYNOPSIS
41.Fd #include <sys/time.h>
42.Fd #include <sys/resource.h>
43.Fd #define RUSAGE_SELF 0
44.Fd #define RUSAGE_CHILDREN -1
45.Ft int
46.Fn getrusage "int who" "struct rusage *rusage"
47.Sh DESCRIPTION
48.Fn Getrusage
49returns information describing the resources utilized by the current
50process, or all its terminated child processes.
51The
52.Fa who
53parameter is either
54.Dv RUSAGE_SELF
55or
56.Dv RUSAGE_CHILDREN .
57The buffer to which
58.Fa rusage
59points will be filled in with
60the following structure:
61.Bd -literal
62struct rusage {
63 struct timeval ru_utime; /* user time used */
64 struct timeval ru_stime; /* system time used */
65 long ru_maxrss; /* integral max resident set size */
66 long ru_ixrss; /* integral shared text memory size */
67 long ru_idrss; /* integral unshared data size */
68 long ru_isrss; /* integral unshared stack size */
69 long ru_minflt; /* page reclaims */
70 long ru_majflt; /* page faults */
71 long ru_nswap; /* swaps */
72 long ru_inblock; /* block input operations */
73 long ru_oublock; /* block output operations */
74 long ru_msgsnd; /* messages sent */
75 long ru_msgrcv; /* messages received */
76 long ru_nsignals; /* signals received */
77 long ru_nvcsw; /* voluntary context switches */
78 long ru_nivcsw; /* involuntary context switches */
79};
80.Ed
81.Pp
82The fields are interpreted as follows:
83.Bl -tag -width ru_minfltaa
84.It Fa ru_utime
85the total amount of time spent executing in user mode.
86.It Fa ru_stime
87the total amount of time spent in the system executing on behalf
88of the process(es).
89.It Fa ru_maxrss
90the maximum resident set size utilized (in kilobytes).
91.It Fa ru_ixrss
92an \*(lqintegral\*(rq value indicating the amount of memory used
93by the text segment
94that was also shared among other processes. This value is expressed
95in units of kilobytes * ticks-of-execution.
96.It Fa ru_idrss
97an integral value of the amount of unshared memory residing in the
98data segment of a process (expressed in units of
99kilobytes * ticks-of-execution).
100.It Fa ru_isrss
101an integral value of the amount of unshared memory residing in the
102stack segment of a process (expressed in units of
103kilobytes * ticks-of-execution).
104.It Fa ru_minflt
105the number of page faults serviced without any I/O activity; here
106I/O activity is avoided by \*(lqreclaiming\*(rq a page frame from
107the list of pages awaiting reallocation.
108.It Fa ru_majflt
109the number of page faults serviced that required I/O activity.
110.It Fa ru_nswap
111the number of times a process was \*(lqswapped\*(rq out of main
112memory.
113.It Fa ru_inblock
114the number of times the file system had to perform input.
115.It Fa ru_oublock
116the number of times the file system had to perform output.
117.It Fa ru_msgsnd
118the number of IPC messages sent.
119.It Fa ru_msgrcv
120the number of IPC messages received.
121.It Fa ru_nsignals
122the number of signals delivered.
123.It Fa ru_nvcsw
124the number of times a context switch resulted due to a process
125voluntarily giving up the processor before its time slice was
126completed (usually to await availability of a resource).
127.It Fa ru_nivcsw
128the number of times a context switch resulted due to a higher
129priority process becoming runnable or because the current process
130exceeded its time slice.
131.El
132.Sh NOTES
133The numbers
134.Fa ru_inblock
135and
136.Fa ru_oublock
137account only for real
138I/O; data supplied by the caching mechanism is charged only
139to the first process to read or write the data.
140.Sh ERRORS
141.Fn Getrusage
142returns -1 on error.
143The possible errors are:
144.Bl -tag -width Er
145.It Bq Er EINVAL
146The
147.Fa who
148parameter is not a valid value.
149.It Bq Er EFAULT
150The address specified by the
151.Fa rusage
152parameter is not in a valid part of the process address space.
153.El
154.Sh SEE ALSO
155.Xr gettimeofday 2 ,
156.Xr wait 2
157.Sh BUGS
158There is no way to obtain information about a child process
159that has not yet terminated.
160.Sh HISTORY
161The
162.Nm
163function call appeared in
164.Bx 4.2 .