xref: /freebsd/lib/libc/gen/times.3 (revision 2e3f49888ec8851bafb22011533217487764fdb0)
1.\" Copyright (c) 1990, 1991, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\" 3. Neither the name of the University nor the names of its contributors
13.\"    may be used to endorse or promote products derived from this software
14.\"    without specific prior written permission.
15.\"
16.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26.\" SUCH DAMAGE.
27.\"
28.Dd December 1, 2008
29.Dt TIMES 3
30.Os
31.Sh NAME
32.Nm times
33.Nd process times
34.Sh LIBRARY
35.Lb libc
36.Sh SYNOPSIS
37.In sys/times.h
38.Ft clock_t
39.Fn times "struct tms *tp"
40.Sh DESCRIPTION
41.Bf -symbolic
42This interface is obsoleted by
43.Xr getrusage 2
44and
45.Xr gettimeofday 2 .
46.Ef
47.Pp
48The
49.Fn times
50function returns the value of time in
51.Dv CLK_TCK Ns 's
52of a second since the system startup time.
53The current value of
54.Dv CLK_TCK ,
55the frequency of the statistics clock in ticks per second, may be
56obtained through the
57.Xr sysconf 3
58interface.
59.Pp
60It also fills in the structure pointed to by
61.Fa tp
62with time-accounting information.
63.Pp
64The
65.Vt tms
66structure is defined as follows:
67.Bd -literal -offset indent
68struct tms {
69	clock_t tms_utime;
70	clock_t tms_stime;
71	clock_t tms_cutime;
72	clock_t tms_cstime;
73};
74.Ed
75.Pp
76The elements of this structure are defined as follows:
77.Bl -tag -width ".Va tms_cutime"
78.It Va tms_utime
79The
80.Tn CPU
81time charged for the execution of user instructions.
82.It Va tms_stime
83The
84.Tn CPU
85time charged for execution by the system on behalf of
86the process.
87.It Va tms_cutime
88The sum of the
89.Va tms_utime Ns s
90and
91.Va tms_cutime Ns s
92of the child processes.
93.It Va tms_cstime
94The sum of the
95.Fa tms_stime Ns s
96and
97.Fa tms_cstime Ns s
98of the child processes.
99.El
100.Pp
101All times are in
102.Dv CLK_TCK Ns 's
103of a second.
104.Pp
105The times of a terminated child process are included in the
106.Va tms_cutime
107and
108.Va tms_cstime
109elements of the parent when one of the
110.Xr wait 2
111functions returns the process ID of the terminated child to the parent.
112If an error occurs,
113.Fn times
114returns the value
115.Pq Po Vt clock_t Pc Ns \-1 ,
116and sets
117.Va errno
118to indicate the error.
119.Sh ERRORS
120The
121.Fn times
122function
123may fail and set the global variable
124.Va errno
125for any of the errors specified for the library
126routines
127.Xr getrusage 2
128and
129.Xr gettimeofday 2 .
130.Sh SEE ALSO
131.Xr time 1 ,
132.Xr getrusage 2 ,
133.Xr gettimeofday 2 ,
134.Xr wait 2 ,
135.Xr sysconf 3 ,
136.Xr clocks 7
137.Sh STANDARDS
138The
139.Fn times
140function
141conforms to
142.St -p1003.1-88 .
143