1GETRUSAGE(2)               Linux Programmer's Manual              GETRUSAGE(2)
2
3
4

NAME

6       getrusage - get resource usage
7

SYNOPSIS

9       #include <sys/time.h>
10       #include <sys/resource.h>
11
12       int getrusage(int who, struct rusage *usage);
13

DESCRIPTION

15       getrusage()  returns  resource usage measures for who, which can be one
16       of the following:
17
18       RUSAGE_SELF
19              Return resource usage statistics for the calling process,  which
20              is the sum of resources used by all threads in the process.
21
22       RUSAGE_CHILDREN
23              Return resource usage statistics for all children of the calling
24              process that have terminated and been waited for.  These statis‐
25              tics  will include the resources used by grandchildren, and fur‐
26              ther removed descendants, if all of the intervening  descendants
27              waited on their terminated children.
28
29       RUSAGE_THREAD (since Linux 2.6.26)
30              Return resource usage statistics for the calling thread.
31
32       The  resource usages are returned in the structure pointed to by usage,
33       which has the following form:
34
35           struct rusage {
36               struct timeval ru_utime; /* user CPU time used */
37               struct timeval ru_stime; /* system CPU time used */
38               long   ru_maxrss;        /* maximum resident set size */
39               long   ru_ixrss;         /* integral shared memory size */
40               long   ru_idrss;         /* integral unshared data size */
41               long   ru_isrss;         /* integral unshared stack size */
42               long   ru_minflt;        /* page reclaims (soft page faults) */
43               long   ru_majflt;        /* page faults (hard page faults) */
44               long   ru_nswap;         /* swaps */
45               long   ru_inblock;       /* block input operations */
46               long   ru_oublock;       /* block output operations */
47               long   ru_msgsnd;        /* IPC messages sent */
48               long   ru_msgrcv;        /* IPC messages received */
49               long   ru_nsignals;      /* signals received */
50               long   ru_nvcsw;         /* voluntary context switches */
51               long   ru_nivcsw;        /* involuntary context switches */
52           };
53
54       Not all fields are completed; unmaintained fields are set  to  zero  by
55       the  kernel.   (The  unmaintained fields are provided for compatibility
56       with other systems, and because  they  may  one  day  be  supported  on
57       Linux.)  The fields are interpreted as follows:
58
59       ru_utime
60              This  is  the total amount of time spent executing in user mode,
61              expressed in a timeval structure (seconds plus microseconds).
62
63       ru_stime
64              This is the total amount of time spent executing in kernel mode,
65              expressed in a timeval structure (seconds plus microseconds).
66
67       ru_maxrss (since Linux 2.6.32)
68              This  is  the maximum resident set size used (in kilobytes). For
69              RUSAGE_CHILDREN, this is the resident set size  of  the  largest
70              child, not the maximum resident set size of the process tree.
71
72       ru_ixrss (unmaintained)
73              This field is currently unused on Linux.
74
75       ru_idrss (unmaintained)
76              This field is currently unused on Linux.
77
78       ru_isrss (unmaintained)
79              This field is currently unused on Linux.
80
81       ru_minflt
82              The  number  of  page  faults serviced without any I/O activity;
83              here I/O activity is avoided by “reclaiming” a page  frame  from
84              the list of pages awaiting reallocation.
85
86       ru_majflt
87              The number of page faults serviced that required I/O activity.
88
89       ru_