Updated: April 19, 2023 |
Get information about resource utilization
#include <sys/resource.h> int getrusage( int who, struct rusage * r_usage );
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
The getrusage() function provides measures of the resources used by the current process or its terminated and waited-for child processes, depending on the value of the who argument.
There's no way to obtain information about a child process that hasn't yet terminated.
The rusage structure includes at least the following two fields:
struct rusage { struct timeval ru_utime; /* user time used */ struct timeval ru_stime; /* system time used */ ... }
There are also __rusage32 and __rusage64 versions of this structure that are specifically for 32- and 64-bit architectures.
The members shown above are the only ones supported by this function. They are:
This structure has other members, but getrusage() doesn't update them and instead sets them all to 0.
Safety: | |
---|---|
Cancellation point | No |
Interrupt handler | No |
Signal handler | Yes |
Thread | Yes |