int
getrusage(
int who
, struct rusage *rusage
)
)
returns information describing the resources used by the current
process, or all its terminated child processes.
The
who
parameter is either
RUSAGE_SELF
or
RUSAGE_CHILDREN
.
The buffer to which
rusage
points will be filled in with
the following structure:
struct rusage {
struct timeval ru_utime; /* user time used */
struct timeval ru_stime; /* system time used */
long ru_maxrss; /* max resident set size */
long ru_ixrss; /* integral shared text memory size */
long ru_idrss; /* integral unshared data size */
long ru_isrss; /* integral unshared stack size */
long ru_minflt; /* page reclaims */
long ru_majflt; /* page faults */
long ru_nswap; /* swaps */
long ru_inblock; /* block input operations */
long ru_oublock; /* block output operations */
long ru_msgsnd; /* messages sent */
long ru_msgrcv; /* messages received */
long ru_nsignals; /* signals received */
long ru_nvcsw; /* voluntary context switches */
long ru_nivcsw; /* involuntary context switches */
};
The fields are interpreted as follows:
ru_utime
ru_stime
ru_maxrss
ru_ixrss
ru_idrss
ru_isrss
ru_minflt
ru_majflt
ru_nswap
ru_inblock
ru_oublock
ru_msgsnd
ru_msgrcv
ru_nsignals
ru_nvcsw
ru_nivcsw
ru_inblock
and
ru_oublock
account only for real
I/O; data supplied by the caching mechanism is charged only
to the first process to read or write the data.
)
returns -1 on error.
The possible errors are:
EINVAL
]
who
parameter is not a valid value.
EFAULT
]
rusage
parameter is not in a valid part of the process address space.
)
function call appeared in
4.2BSD.