GETRUSAGE(2)
NAME
getrusage − get information about resource utilization
USAGE
#include <sys/time.h> #include <sys/resource.h>
#define RUSAGE_SELF 0 /* calling process */ #define RUSAGE_CHILDREN -1 /* terminated child processes */
getrusage(who, rusage) int who; struct rusage *rusage;
DESCRIPTION
The getrusage call returns information describing the resources used by the current process or all of its terminated child processes. The who parameter is one of RUSAGE_SELF and RUSAGE_CHILDREN. If rusage is non-zero, the buffer it points to will be occupied by the following structure: struct rusage { struct timeval ru_utime; /* user time used */ struct timeval ru_stime; /* system time used */ int ru_maxrss; int ru_ixrss; /* integral shared memory size */ int ru_idrss; /* integral unshared data size */ int ru_isrss; /* integral unshared stack size */ int ru_minflt; /* page reclaims */ int ru_majflt; /* page faults */ int ru_nswap; /* swaps */ int ru_inblock /* block input operations */ int ru_oublock; /* block output operations */ int ru_msgsnd; /* messages sent */ int ru_msgrcv; /* messages received */ int ru_nsignals; /* signals received */ int ru_nvcsw; /* voluntary context switches */ int ru_nivcsw; /* involuntary context switches */ }; Currently, only the following fields are meaningful to DOMAIN/IX operations:
ru_utime Total amount of time spent executing in user mode.
ru_majflt Number of page faults serviced that required I/O activity.
ru_nsignals Number of signals delivered.
The remaining fields are returned as zero. Moreover, the only information returned about child processes is user time (ru_time); all other fields are returned as zero.
CAUTIONS
There is no way to obtain information about a child process that has not yet terminated.