times(2) CLIX times(2)
NAME
times - Gets process and child process times
LIBRARY
Standard C Library (libc.a)
SYNOPSIS
#include <sys/times.h>
clock_t times(
struct tms *buffer );
PARAMETERS
buffer Points to the tms structure where system time information is
stored.
DESCRIPTION
The times() function fills the tms structure space pointed to by buffer
with time-accounting information. All time values reported by this
function are in hardware-dependent clock ticks. A single clock tick is
1/HZ of the system fundamental clock frequency HZ, found in <sys/param.h>
where HZ is in Hertz.
The times of a terminated child process are included in the tms_cutime and
tms_cstime elements of the parent process when a wait() or waitpid()
function returns the process ID of that terminated child.
The tms structure, which is defined in the <sys/times.h> header file
contains the following members:
time_t tms_utime
User time. The CPU time used while executing user instructions of
the calling process.
time_t tms_stime
System time. The CPU time used during system execution on behalf
of the calling process.
time_t tms_cutime
User time for children. The sum of the tms_utime and the total
tms_cutime times of the child processes.
time_t tms_cstime
System time for children. The sum of the tms_stime and the total
tms_cstime times of the child processes.
2/94 - Intergraph Corporation 1
times(2) CLIX times(2)
When a child process does not wait for its children, its child-process
times are not included in its times.
EXAMPLES
To determine the amount of time consumed by a process, as well as the
amount of time consumed by the process and all its children:
struct tms elapsed_time;
if (times(&elapsed_time) == (clock_t)-1)
perror("times failed");
RETURN VALUES
On successful completion, times() returns the elapsed real time in clock
ticks since an arbitrary reference time in the past (for example, system
start up time). This reference time does not change from one times()
invocation to another. When times() fails, a value of ((clock_t) - 1) is
returned and the global variable errno is set to indicate the error.
ERRORS
The times() function fails when the following is true:
[EFAULT] The buffer parameter points to an inaccessible address.
RELATED INFORMATION
Functions: exec(2), fork(2), time(2), sysconf(2), wait(2), waitpid(2)
2 Intergraph Corporation - 2/94