1.\" $OpenBSD: times.3,v 1.17 2024/07/01 00:05:43 jsg 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 1 2024 $ 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 clock_gettime 2 44and 45.Xr getrusage 2 . 46.Ef 47.Pp 48The 49.Fn times 50function fills in the structure pointed to by 51.Fa tp 52with time-accounting information. 53.Pp 54The 55.Vt tms 56structure is defined as follows: 57.Bd -literal -offset indent 58struct tms { 59 clock_t tms_utime; 60 clock_t tms_stime; 61 clock_t tms_cutime; 62 clock_t tms_cstime; 63}; 64.Ed 65.Pp 66The elements of this structure are defined as follows: 67.Bl -tag -width tms_cutime 68.It Fa tms_utime 69The 70.Tn CPU 71time charged for the execution of user instructions. 72.It Fa tms_stime 73The 74.Tn CPU 75time charged for execution by the system on behalf of 76the process. 77.It Fa tms_cutime 78The sum of 79.Fa tms_utime 80and 81.Fa tms_cutime 82for all of the child processes. 83.It Fa tms_cstime 84The sum of 85.Fa tms_stime 86and 87.Fa tms_cstime 88for all of the child processes. 89.El 90.Pp 91All times are in 92.Dv CLK_TCK Ns s 93of a second. 94.Pp 95The times of a terminated child process are included in the 96.Fa tms_cutime 97and 98.Fa tms_cstime 99elements of the parent when one of the 100.Xr wait 2 101functions returns the process ID of the terminated child to the parent. 102.Sh RETURN VALUES 103Upon successful completion, 104.Fn times 105returns the value of real time, 106in 107.Dv CLK_TCK Ns s 108of a second, 109elapsed since an arbitrary point in the past. 110This point does not change between invocations of 111.Fn times 112so two such return values constitute a real time interval. 113.Pp 114On failure, 115.Fn times 116returns 117.Li "(clock_t)-1" 118and the global variable 119.Va errno 120is set to indicate the error. 121.Sh ERRORS 122The 123.Fn times 124function may fail and set 125.Va errno 126for any of the errors specified for 127.Xr clock_gettime 2 128and 129.Xr getrusage 2 . 130.Sh SEE ALSO 131.Xr time 1 , 132.Xr clock_gettime 2 , 133.Xr getrusage 2 , 134.Xr wait 2 135.Sh STANDARDS 136The 137.Fn times 138function conforms to 139.St -p1003.1-88 . 140.Sh HISTORY 141A 142.Fn times 143function first appeared in 144.At v3 . 145