Gets information about resource utilization. Format #incloude <sys/resource.h> int getrusage (int who, struct rusage *r_usage);
1 – Arguments
who The process you want to get the resource usage for. r_usage A pointer to an object of type struct rusage in which the function can store the resource usage information.
2 – Description
The getrusage function provides measures of the resources used by the current process or its terminated and waited-for child processes. If the value of the who argument is RUSAGE_SELF, information is returned about resources used by the current process. If the value of the who argument is RUSAGE_CHILDREN, information is returned about resources used by the terminated and waited-for children of the current process. If the child is never waited for, the resource information for the child process is discarded and not included in the resource information provided by getrusage. Currently, only getting elapsed user time (ru_utime) and maximum resident memory (ru_maxrss) is supported.
3 – Return Values
0 Successful completion. -1 Indicates an error. errno contains the error.