1GETRUSAGE(3P)              POSIX Programmer's Manual             GETRUSAGE(3P)
2
3
4

PROLOG

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

NAME

12       getrusage — get information about resource utilization
13

SYNOPSIS

15       #include <sys/resource.h>
16
17       int getrusage(int who, struct rusage *r_usage);
18

DESCRIPTION

20       The getrusage() function shall provide measures of the  resources  used
21       by  the  current  process  or  its terminated and waited-for child pro‐
22       cesses. If the value of the who argument  is  RUSAGE_SELF,  information
23       shall  be  returned about resources used by the current process. If the
24       value of the who argument  is  RUSAGE_CHILDREN,  information  shall  be
25       returned about resources used by the terminated and waited-for children
26       of the current process. If the child is never waited for (for  example,
27       if  the  parent  has  SA_NOCLDWAIT set or sets SIGCHLD to SIG_IGN), the
28       resource information  for  the  child  process  is  discarded  and  not
29       included in the resource information provided by getrusage().
30
31       The r_usage argument is a pointer to an object of type struct rusage in
32       which the returned information is stored.
33

RETURN VALUE

35       Upon successful completion, getrusage() shall return 0;  otherwise,  -1
36       shall be returned and errno set to indicate the error.
37

ERRORS

39       The getrusage() function shall fail if:
40
41       EINVAL The value of the who argument is not valid.
42
43       The following sections are informative.
44

EXAMPLES

46   Using getrusage()
47       The  following  example returns information about the resources used by
48       the current process.
49
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

APPLICATION USAGE

60       None.
61

RATIONALE

63       None.
64

FUTURE DIRECTIONS

66       None.
67

SEE ALSO

69       exit(), sigaction(), time(), times(), wait()
70
71       The Base Definitions volume of POSIX.1‐2017, <sys_resource.h>
72
74       Portions of this text are reprinted and reproduced in  electronic  form
75       from  IEEE Std 1003.1-2017, Standard for Information Technology -- Por‐
76       table Operating System Interface (POSIX), The Open Group Base  Specifi‐
77       cations  Issue  7, 2018 Edition, Copyright (C) 2018 by the Institute of
78       Electrical and Electronics Engineers, Inc and The Open Group.   In  the
79       event of any discrepancy between this version and the original IEEE and
80       The Open Group Standard, the original IEEE and The Open Group  Standard
81       is  the  referee document. The original Standard can be obtained online
82       at http://www.opengroup.org/unix/online.html .
83
84       Any typographical or formatting errors that appear  in  this  page  are
85       most likely to have been introduced during the conversion of the source
86       files to man page format. To report such errors,  see  https://www.ker
87       nel.org/doc/man-pages/reporting_bugs.html .
88
89
90
91IEEE/The Open Group                  2017                        GETRUSAGE(3P)
Impressum