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
12 getrusage - get information about resource utilization
13
15 #include <sys/resource.h>
16
17 int getrusage(int who, struct rusage *r_usage);
18
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
45 The following sections are informative.
46
48 Using getrusage()
49 The following example returns information about the resources used by
50 the current process.
51
52
53 #include <sys/resource.h>
54 ...
55 int who = RUSAGE_SELF;
56 struct rusage usage;
57 int ret;
58
59
60 ret = getrusage(who, &usage);
61
63 None.
64
66 None.
67
69 None.
70
72 exit(), sigaction(), time(), times(), wait(), the Base Definitions vol‐
73 ume of IEEE Std 1003.1-2001, <sys/resource.h>
74
76 Portions of this text are reprinted and reproduced in electronic form
77 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
78 -- Portable Operating System Interface (POSIX), The Open Group Base
79 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
80 Electrical and Electronics Engineers, Inc and The Open Group. In the
81 event of any discrepancy between this version and the original IEEE and
82 The Open Group Standard, the original IEEE and The Open Group Standard
83 is the referee document. The original Standard can be obtained online
84 at http://www.opengroup.org/unix/online.html .
85
86
87
88IEEE/The Open Group 2003 GETRUSAGE(3P)