xref: /openbsd/lib/libc/gen/times.3 (revision 5af055cd)
1.\"	$OpenBSD: times.3,v 1.14 2013/07/17 05:42:11 schwarze Exp $
2.\"
3.\" Copyright (c) 1990, 1991, 1993
4.\"	The Regents of the University of California.  All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\" 3. Neither the name of the University nor the names of its contributors
15.\"    may be used to endorse or promote products derived from this software
16.\"    without specific prior written permission.
17.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28.\" SUCH DAMAGE.
29.\"
30.Dd $Mdocdate: July 17 2013 $
31.Dt TIMES 3
32.Os
33.Sh NAME
34.Nm times
35.Nd process times
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
530 hours, 0 minutes, 0 seconds, January 1, 1970, Coordinated Universal
54Time (UTC).
55.Pp
56It also fills in the structure pointed to by
57.Fa tp
58with time-accounting information.
59.Pp
60The
61.Li tms
62structure is defined as follows:
63.Bd -literal -offset indent
64struct tms {
65	clock_t tms_utime;
66	clock_t tms_stime;
67	clock_t tms_cutime;
68	clock_t tms_cstime;
69};
70.Ed
71.Pp
72The elements of this structure are defined as follows:
73.Bl -tag -width tms_cutime
74.It Fa tms_utime
75The
76.Tn CPU
77time charged for the execution of user instructions.
78.It Fa tms_stime
79The
80.Tn CPU
81time charged for execution by the system on behalf of
82the process.
83.It Fa tms_cutime
84The sum of
85.Fa tms_utime
86and
87.Fa tms_cutime
88for all of the child processes.
89.It Fa tms_cstime
90The sum of
91.Fa tms_stime
92and
93.Fa tms_cstime
94for all of the child processes.
95.El
96.Pp
97All times are in
98.Dv CLK_TCK Ns s
99of a second.
100.Pp
101The times of a terminated child process are included in the
102.Fa tms_cutime
103and
104.Fa tms_cstime
105elements of the parent when one of the
106.Xr wait 2
107functions returns the process ID of the terminated child to the parent.
108If an error occurs,
109.Fn times
110returns the value
111.Li "(clock_t)-1" ,
112and sets
113.Va errno
114to indicate the error.
115.Sh ERRORS
116The
117.Fn times
118function may fail and set the global variable
119.Va errno
120for any of the errors specified for the library
121routines
122.Xr getrusage 2
123and
124.Xr gettimeofday 2 .
125.Sh SEE ALSO
126.Xr time 1 ,
127.Xr getrusage 2 ,
128.Xr gettimeofday 2 ,
129.Xr wait 2
130.Sh STANDARDS
131The
132.Fn times
133function conforms to
134.St -p1003.1-88 .
135.Sh HISTORY
136A
137.Fn times
138function first appeared in
139.At v3 .
140The tms structure first appeared in
141.Bx 4.0
142and was changed to use
143.Vt clock_t
144instead of
145.Vt time_t
146for its members in
147.Bx 4.3 Net/2 .
148