Description
Exercise #2
Create the program 'rusage
' that will run a program provided on the command
line and then print out the resources used by the process using the system call
getrusage(2)
. Read the man page in section 2 of the online manual for the API
information on the getrusage
system call.
View the working version to produce the same output.
The timeval structure (documented in the timeradd(3)
man page):
struct timeval {
time_t tv_sec; /* seconds */
suseconds_t tv_usec; /* microseconds */
};
There are 1 million microseconds in a second (i.e. divide the microseconds by 1 million to get the fractional second.)