386BSD 0.1 development
[unix-history] / usr / src / lib / libc / gen / times.3
CommitLineData
8168e750
WJ
1.\" Copyright (c) 1990, 1991 The Regents of the University of California.
2.\" 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 6.4 (Berkeley) 4/19/91
33.\"
34.Dd April 19, 1991
35.Dt TIMES 3
36.Os BSD 4
37.Sh NAME
38.Nm times
39.Nd process times
40.Sh SYNOPSIS
41.Fd #include <sys/times.h>
42.Ft clock_t
43.Fn times "struct tms *tp"
44.Sh DESCRIPTION
45.Bf -symbolic
46This interface is obsoleted by getrusage(2)
47and gettimeofday(3).
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
550 hours, 0 minutes, 0 seconds, January 1, 1970, Coordinated Universal
56Time.
57.Pp
58It also fills in the structure pointed to by
59.Fa tp
60with time-accounting information.
61.Pp
62The
63.Fa tms
64structure is defined as follows:
65.Bd -literal -offset indent
66typedef struct {
67 clock_t tms_utime;
68 clock_t tms_stime;
69 clock_t tms_cutime;
70 clock_t tms_cstime;
71}
72.Ed
73.Pp
74The elements of this structure are defined as follows:
75.Bl -tag -width tms_cutime
76.It Fa tms_utime
77The
78.Tn CPU
79time charged for the execution of user instructions.
80.It Fa tms_stime
81The
82.Tn CPU
83time charged for execution by the system on behalf of
84the process.
85.It Fa tms_cutime
86The sum of the
87.Fa tms_utime s
88and
89.Fa tms_cutime s
90of the child processes.
91.It Fa tms_cstime
92The sum of the
93.Fa tms_stime Ns s
94and
95.Fa tms_cstime Ns s
96of the child processes.
97.El
98.Pp
99All times are in
100.Dv CLK_TCK Ns 's
101of a second.
102.Pp
103The times of a terminated child process are included in the
104.Fa tms_cutime
105and
106.Fa tms_cstime
107elements of the parent when one of the
108.Xr wait 2
109functions returns the process ID of the terminated child to the parent.
110If an error occurs,
111.Fn times
112returns the value
113.Pq (clock_t)\-1 ,
114and sets errno to indicate the error.
115.Sh ERRORS
116The
117.Fn times
118function
119may fail and set the global variable
120.Va errno
121for any of the errors specified for the library
122routines
123.Xr getrusage 2
124and
125.Xr gettimeofday 2 .
126.Sh SEE ALSO
127.Xr time 1 ,
128.Xr getrusage 2 ,
129.Xr gettimeofday 2 ,
130.Xr wait 2
131.Sh STANDARDS
132The
133.Fn times
134function
135conforms to
136.St -p1003.1-88 .