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