]>
Commit | Line | Data |
---|---|---|
e3a887db MK |
1 | .\" Hey Emacs! This file is -*- nroff -*- source. |
2 | .\" | |
3 | .\" Copyright (c) 1992 Drew Eckhardt, March 28, 1992 | |
6883b3e7 | 4 | .\" and Copyright (c) 2002 Michael Kerrisk |
e3a887db MK |
5 | .\" |
6 | .\" Permission is granted to make and distribute verbatim copies of this | |
7 | .\" manual provided the copyright notice and this permission notice are | |
8 | .\" preserved on all copies. | |
9 | .\" | |
10 | .\" Permission is granted to copy and distribute modified versions of this | |
11 | .\" manual under the conditions for verbatim copying, provided that the | |
12 | .\" entire resulting derived work is distributed under the terms of a | |
13 | .\" permission notice identical to this one. | |
14 | .\" | |
15 | .\" Since the Linux kernel and libraries are constantly changing, this | |
16 | .\" manual page may be incorrect or out-of-date. The author(s) assume no | |
17 | .\" responsibility for errors or omissions, or for damages resulting from | |
18 | .\" the use of the information contained herein. The author(s) may not | |
19 | .\" have taken the same level of care in the production of this manual, | |
20 | .\" which is licensed free of charge, as they might when working | |
21 | .\" professionally. | |
22 | .\" | |
23 | .\" Formatted or processed versions of this manual, if unaccompanied by | |
24 | .\" the source, must acknowledge the copyright and authors of this work. | |
25 | .\" | |
704a18f0 MK |
26 | .\" 2004-11-16 -- mtk: the getrlimit.2 page, which formerly included |
27 | .\" coverage of getrusage(2), has been split, so that the latter is | |
28 | .\" now covered in its own getrusage.2. For older details of change | |
e3a887db MK |
29 | .\" history, etc, see getrlimit.2 |
30 | .\" | |
31 | .\" Modified 2004-11-16, mtk, Noted that the non-conformance | |
32 | .\" when SIGCHLD is being ignored is fixed in 2.6.9. | |
33 | .\" | |
c10859eb | 34 | .TH GETRUSAGE 2 2004-11-16 "Linux 2.6.9" "Linux Programmer's Manual" |
e3a887db MK |
35 | .SH NAME |
36 | getrusage \- get resource usage | |
37 | .SH SYNOPSIS | |
38 | .B #include <sys/time.h> | |
39 | .br | |
40 | .B #include <sys/resource.h> | |
41 | .sp | |
42 | .BI "int getrusage(int " who ", struct rusage *" usage ); | |
43 | .SH DESCRIPTION | |
44 | .PP | |
45 | .BR getrusage () | |
46 | returns current resource usages, for a \fIwho\fP | |
47 | of either | |
48 | .B RUSAGE_SELF | |
49 | or | |
50 | .BR RUSAGE_CHILDREN . | |
51 | The former asks for resources used by the current process, | |
52 | the latter for resources used by those of its children | |
53 | that have terminated and have been waited for. | |
54 | .PP | |
55 | .in +0.5i | |
56 | .nf | |
57 | struct rusage { | |
58 | struct timeval ru_utime; /* user time used */ | |
59 | struct timeval ru_stime; /* system time used */ | |
60 | long ru_maxrss; /* maximum resident set size */ | |
61 | long ru_ixrss; /* integral shared memory size */ | |
62 | long ru_idrss; /* integral unshared data size */ | |
63 | long ru_isrss; /* integral unshared stack size */ | |
64 | long ru_minflt; /* page reclaims */ | |
65 | long ru_majflt; /* page faults */ | |
66 | long ru_nswap; /* swaps */ | |
67 | long ru_inblock; /* block input operations */ | |
68 | long ru_oublock; /* block output operations */ | |
69 | long ru_msgsnd; /* messages sent */ | |
70 | long ru_msgrcv; /* messages received */ | |
71 | long ru_nsignals; /* signals received */ | |
72 | long ru_nvcsw; /* voluntary context switches */ | |
73 | long ru_nivcsw; /* involuntary context switches */ | |
74 | }; | |
75 | .fi | |
76 | .in -0.5i | |
77 | .SH "RETURN VALUE" | |
78 | On success, zero is returned. On error, \-1 is returned, and | |
79 | .I errno | |
80 | is set appropriately. | |
81 | .SH ERRORS | |
82 | .TP | |
83 | .B EFAULT | |
84 | .I usage | |
85 | points outside the accessible address space. | |
86 | .TP | |
87 | .B EINVAL | |
88 | .I who | |
89 | is invalid. | |
90 | .SH "CONFORMING TO" | |
97c1eac8 MK |
91 | SVr4, 4.3BSD. |
92 | POSIX.1-2001 specifies | |
93 | .BR getrusage (), | |
94 | but only specifies the fields | |
95 | .I ru_utime | |
96 | and | |
97 | .IR ru_stime . | |
e3a887db MK |
98 | .SH NOTES |
99 | Including | |
100 | .I <sys/time.h> | |
101 | is not required these days, but increases portability. | |
102 | (Indeed, | |
103 | .I struct timeval | |
104 | is defined in | |
105 | .IR <sys/time.h> .) | |
106 | .PP | |
107 | In Linux kernel versions before 2.6.9, if the disposition of | |
108 | .B SIGCHLD | |
109 | is set to | |
110 | .B SIG_IGN | |
111 | then the resource usages of child processes | |
112 | are automatically included in the value returned by | |
113 | .BR RUSAGE_CHILDREN , | |
97c1eac8 | 114 | although POSIX.1-2001 explicitly prohibits this. |
e3a887db MK |
115 | This non-conformance is rectified in Linux 2.6.9 and later. |
116 | .\" See the description of getrusage() in XSH. | |
117 | .\" A similar statement was also in SUSv2. | |
118 | .LP | |
b14d4aa5 | 119 | The above struct was taken from 4.3BSD Reno. |
e3a887db | 120 | Not all fields are meaningful under Linux. |
dd61d68c MK |
121 | In linux 2.4 only the fields |
122 | .IR ru_utime , | |
123 | .IR ru_stime , | |
124 | .IR ru_minflt , | |
e3a887db | 125 | and |
dd61d68c | 126 | .IR ru_majflt |
e3a887db | 127 | are maintained. |
dd61d68c MK |
128 | Since Linux 2.6, |
129 | .I ru_nvcsw | |
130 | and | |
131 | .I ru_nivcsw | |
132 | are also maintained. | |
e3a887db MK |
133 | .SH "SEE ALSO" |
134 | .BR getrlimit (2), | |
135 | .BR times (2), | |
136 | .BR wait (2), | |
137 | .BR wait4 (2) |