1GETRUSAGE(3P) POSIX Programmer's Manual GETRUSAGE(3P)
2
3
4
6 This manual page is part of the POSIX Programmer's Manual. The Linux
7 implementation of this interface may differ (consult the corresponding
8 Linux manual page for details of Linux behavior), or the interface may
9 not be implemented on Linux.
10
11
13 getrusage — get information about resource utilization
14
16 #include <sys/resource.h>
17
18 int getrusage(int who, struct rusage *r_usage);
19
21 The getrusage() function shall provide measures of the resources used
22 by the current process or its terminated and waited-for child pro‐
23 cesses. If the value of the who argument is RUSAGE_SELF, information
24 shall be returned about resources used by the current process. If the
25 value of the who argument is RUSAGE_CHILDREN, information shall be
26 returned about resources used by the terminated and waited-for children
27 of the current process. If the child is never waited for (for example,
28 if the parent has SA_NOCLDWAIT set or sets SIGCHLD to SIG_IGN), the
29 resource information for the child process is discarded and not
30 included in the resource information provided by getrusage().
31
32 The r_usage argument is a pointer to an object of type struct rusage in
33 which the returned information is stored.
34
36 Upon successful completion, getrusage() shall return 0; otherwise, −1
37 shall be returned and errno set to indicate the error.
38
40 The getrusage() function shall fail if:
41
42 EINVAL The value of the who argument is not valid.
43
44 The following sections are informative.
45
47 Using getrusage()
48 The following example returns information about the resources used by
49 the current process.
50
51 #include <sys/resource.h>
52 ...
53 int who = RUSAGE_SELF;
54 struct rusage usage;
55 int ret;
56
57 ret = getrusage(who, &usage);
58
60 None.
61
63 None.
64
66 None.
67
69 exit(), sigaction(), time(), times(), wait()
70
71 The Base Definitions volume of POSIX.1‐2008, <sys_resource.h>
72
74 Portions of this text are reprinted and reproduced in electronic form
75 from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
76 -- Portable Operating System Interface (POSIX), The Open Group Base
77 Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
78 cal and Electronics Engineers, Inc and The Open Group. (This is
79 POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) In the
80 event of any discrepancy between this version and the original IEEE and
81 The Open Group Standard, the original IEEE and The Open Group Standard
82 is the referee document. The original Standard can be obtained online
83 at http://www.unix.org/online.html .
84
85 Any typographical or formatting errors that appear in this page are
86 most likely to have been introduced during the conversion of the source
87 files to man page format. To report such errors, see https://www.ker‐
88 nel.org/doc/man-pages/reporting_bugs.html .
89
90
91
92IEEE/The Open Group 2013 GETRUSAGE(3P)