Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

getrusage, getrusage64 - get information on usage of resources

&pagelevel(4)&pagelevel

Syntax

#include <sys/resource.h>

int getrusage(int who, struct rusage *r_usage); 

CRTE111A30

int getrusage64(int who, struct rusage64 *r_usage); (End)

Description

getrusage() returns information on the resources used by the current process or its terminated child processes and the child processes whose termination the process is waiting for.

The who argument can contain the value RUSAGE_SELF or RUSAGE_CHILDREN. In the first case, information on the resources of the current process is returned. In the second case, getrusage() outputs information on the resources of the terminated child processes of the current process and the resources of the child process which the current process is waiting for. If the process never waits for a child process, e.g. because SA_NOCLDWAIT is set in the parent process or SIGCHLD is set to SIG_IGN, no information on the resource usage of the child process will be returned.

The function getrusage64() behaves like the function getrusage(), except that the argument r_usage points to a structure rusage instead of a structure rusage.

The structure rusage contains the following components:

struct timeval ru_utime    /* The total time the execution takes in user mode.
                              The interval is specified in seconds and 
                              microseconds. */
struct timeval ru_stime    /* The total time the execution takes in system
                              mode. The interval is specified in seconds and
                              microseconds. */

The structure rusage64 contains the following components:

struct timeval64 ru_utime    /* The total time the execution takes in user mode.
                                The interval is specified in seconds and 
                                microseconds. */
struct timeval64 ru_stime    /* The total time the execution takes in system
                                mode. The interval is specified in seconds and
                                microseconds. */ 

Return val.

0

if successful. The rusage structure is filled up with the corresponding values.

-1

if an error occurs. errno is set to indicate the error.

Errors

getrusage() and getrusage64() will fail if: 


EINVAL

The who argument does not contain a valid value.


Extension


EFAULT

The address specified by the r_usage argument is not a valid area of the address area of the process. (End)


getrusage64() will fail if:

 

ENOSYS

POSIX-BC correction status < A47.

See also

exit(), gettimeofday(), read(), sigaction(), time(), times(), wait(), write(), sys/resource.h.