xref: /freebsd/lib/libc/gen/times.3 (revision 26a58599a09a6181e0f5abe624021865a0c23186)
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.\"     @(#)times.3	8.1 (Berkeley) 6/4/93
29.\"
30.Dd December 1, 2008
31.Dt TIMES 3
32.Os
33.Sh NAME
34.Nm times
35.Nd process times
36.Sh LIBRARY
37.Lb libc
38.Sh SYNOPSIS
39.In sys/times.h
40.Ft clock_t
41.Fn times "struct tms *tp"
42.Sh DESCRIPTION
43.Bf -symbolic
44This interface is obsoleted by
45.Xr getrusage 2
46and
47.Xr gettimeofday 2 .
48.Ef
49.Pp
50The
51.Fn times
52function returns the value of time in
53.Dv CLK_TCK Ns 's
54of a second since the system startup time.
55The current value of
56.Dv CLK_TCK ,
57the frequency of the statistics clock in ticks per second, may be
58obtained through the
59.Xr sysconf 3
60interface.
61.Pp
62It also fills in the structure pointed to by
63.Fa tp
64with time-accounting information.
65.Pp
66The
67.Vt tms
68structure is defined as follows:
69.Bd -literal -offset indent
70struct tms {
71	clock_t tms_utime;
72	clock_t tms_stime;
73	clock_t tms_cutime;
74	clock_t tms_cstime;
75};
76.Ed
77.Pp
78The elements of this structure are defined as follows:
79.Bl -tag -width ".Va tms_cutime"
80.It Va tms_utime
81The
82.Tn CPU
83time charged for the execution of user instructions.
84.It Va tms_stime
85The
86.Tn CPU
87time charged for execution by the system on behalf of
88the process.
89.It Va tms_cutime
90The sum of the
91.Va tms_utime Ns s
92and
93.Va tms_cutime Ns s
94of the child processes.
95.It Va tms_cstime
96The sum of the
97.Fa tms_stime Ns s
98and
99.Fa tms_cstime Ns s
100of the child processes.
101.El
102.Pp
103All times are in
104.Dv CLK_TCK Ns 's
105of a second.
106.Pp
107The times of a terminated child process are included in the
108.Va tms_cutime
109and
110.Va tms_cstime
111elements of the parent when one of the
112.Xr wait 2
113functions returns the process ID of the terminated child to the parent.
114If an error occurs,
115.Fn times
116returns the value
117.Pq Po Vt clock_t Pc Ns \-1 ,
118and sets
119.Va errno
120to indicate the error.
121.Sh ERRORS
122The
123.Fn times
124function
125may fail and set the global variable
126.Va errno
127for any of the errors specified for the library
128routines
129.Xr getrusage 2
130and
131.Xr gettimeofday 2 .
132.Sh SEE ALSO
133.Xr time 1 ,
134.Xr getrusage 2 ,
135.Xr gettimeofday 2 ,
136.Xr wait 2 ,
137.Xr sysconf 3 ,
138.Xr clocks 7
139.Sh STANDARDS
140The
141.Fn times
142function
143conforms to
144.St -p1003.1-88 .
145