The function getrusage and the data type struct rusage
are used to examine the resource usage of a process. They are declared
in `sys/resource.h'.
*rusage.
In most systems, processes has only two valid values:
RUSAGE_SELF
RUSAGE_CHILDREN
In the GNU system, you can also inquire about a particular child process by specifying its process ID.
The return value of getrusage is zero for success, and -1
for failure.
EINVAL
One way of getting resource usage for a particular child process is with
the function wait4, which returns totals for a child when it
terminates. See section BSD Process Wait Functions.
struct timeval ru_utime
struct timeval ru_stime
long int ru_maxrss
long int ru_ixrss
long int ru_idrss
long int ru_isrss
long int ru_minflt
long int ru_majflt
long int ru_nswap
long int ru_inblock
long int ru_oublock
long int ru_msgsnd
long int ru_msgrcv
long int ru_nsignals
long int ru_nvcsw
long int ru_nivcsw
vtimes is a historical function that does some of what
getrusage does. getrusage is a better choice.
vtimes and its vtimes data structure are declared in
`sys/vtimes.h'.
vtimes reports resource usage totals for a process.
If current is non-null, vtimes stores resource usage totals for
the invoking process alone in the structure to which it points. If
child is non-null, vtimes stores resource usage totals for all
past children (which have terminated) of the invoking process in the structure
to which it points.
struct rusage data type
described above.
vm_utime
ru_utime in struct rusage
vm_stime
ru_stime in struct rusage
vm_idsrss
ru_idrss and ru_isrss in struct rusage
vm_ixrss
ru_ixrss in struct rusage
vm_maxrss
ru_maxrss in
struct rusage
vm_majflt
ru_majflt in struct rusage
vm_minflt
ru_minflt in struct rusage
vm_nswap
ru_nswap in struct rusage
vm_inblk
ru_inblk in struct rusage
vm_oublk
ru_oublk in struct rusage
The return value is zero if the function succeeds; -1 otherwise.
An additional historical function for examining resource usage,
vtimes, is supported but not documented here. It is declared in
`sys/vtimes.h'.
Go to the first, previous, next, last section, table of contents.