The Linux Programming Interface

(nextflipdebug5) #1

Chapter 36: Process Resources


Each process consumes system resources such as memory and CPU time. This
chapter looks at resource-related system calls. We begin with the getrusage() system
call, which allows a process to monitor the resources that it has used or that its children
have used. We then look at the setrlimit() and getrlimit() system calls, which can be
used to change and retrieve limits on the calling process’s consumption of various
resources.

36.1 Process Resource Usage


The getrusage() system call retrieves statistics about various system resources used
by the calling process or by all of its children.

#include <sys/resource.h>

int getrusage(int who, struct rusage *res_usage);
Returns 0 on success, or –1 on error
Free download pdf