getrusage() - get information about use of resources
#include <sys/resource.h>
int getrusage (int who, struct rusage *r_usage)
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:
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>).
After successful completion, the getrusage(2) call returns 0; after a failure, it returns -1 and sets errno to indicate the error.
The getrusage(2) call can fail for the following reasons:
sigaction(2)
time(2)
times(2)
wait(2)
exit(3)