getrusage()

NAME

getrusage() - get information about use of resources

SYNOPSIS

#include <sys/resource.h>

int getrusage (int who, struct rusage *r_usage)

DESCRIPTION

The getrusage(2) call reports on the use of resources by the current process or its child processes, if they are terminated or waited-for. The who argument determines which processes the getrusage(2) call reports on:

RUSAGE_SELF
Report on the resources used by the calling process.
RUSAGE_CHILDREN
Report on the resources used by any children processes that have been terminated or that are waited-for. If a child process is not being waited for, perhaps because the parent has SA_NOCLDWAIT set, or has set SIGCHLD to SIG_IGN, then that child process's resource information is not included.

The argument r_usage points to an object to contain the resource usage information. The object is of the type struct rusage (defined in <sys/resource.h>).

RETURN VALUE

After successful completion, the getrusage(2) call returns 0; after a failure, it returns -1 and sets errno to indicate the error.

ERRORS

The getrusage(2) call can fail for the following reasons:

[EINVAL]
The who argument is not valid.

SEE ALSO

sigaction(2)

time(2)

times(2)

wait(2)

exit(3)