#define RUSAGE_SELF 1 #define RUSAGE_CHILDREN 2 struct rusage { struct timeval ru_utime; // user CPU time used. struct timeval ru_stime; // system CPU time used. }; int getusage(int who, struct rusage *usage);
This syscall gets the use of several resources by a process.
Unlike what POSIX mandates, this syscall will always need remaining
to
be a valid structure. clock_id
takes the same value as clock.
Due to implementation details, for now, system time does include waiting time, but given this syscall’s information is merely advisory, it may be changed later.
who
establishes who to request the information for, it can be one of:
RUSAGE_SELF
Get information for the callee process.
RUSAGE_CHILDREN
Get information for all of the children processes.
The syscall returns 0
on success or -1
on failure, with the
following errno:
EFAULT
usage
point to non accessible memory.
EINVAL
who
was not valid.