1 .\" Hey Emacs! This file is -*- nroff -*- source.
3 .\" Copyright (c) 1992 Drew Eckhardt (drew@cs.colorado.edu), March 28, 1992
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date. The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein. The author(s) may not
18 .\" have taken the same level of care in the production of this manual,
19 .\" which is licensed free of charge, as they might when working
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
25 .\" Modified by Michael Haardt (michael@moria.de)
26 .\" Modified Sat Jul 24 14:29:17 1993 by Rik Faith (faith@cs.unc.edu)
27 .\" Modified 961203 and 001211 and 010326 by aeb@cwi.nl
28 .\" Modified 001213 by Michael Haardt (michael@moria.de)
29 .\" Modified 13 Jun 02, Michael Kerrisk <mtk-manpages@gmx.net>
30 .\" Added note on non-standard behaviour when SIGCHLD is ignored.
31 .\" Modified 2004-11-16, mtk, Noted that the non-conformance when
32 .\" SIGCHLD is being ignored is fixed in 2.6.9; other minor changes
33 .\" Modified 2004-12-08, mtk, in 2.6 times() return value changed
35 .\" Added notes on non-standard behaviour: Linux allows 'buf' to
36 .\" be NULL, but POSIX.1 doesn't specify this and it's non-portable.
38 .TH TIMES 2 2002-06-14 "Linux" "Linux Programmer's Manual"
40 times \- get process times
42 .B #include <sys/times.h>
44 .BI "clock_t times(struct tms *" buf );
47 stores the current process times in the
60 clock_t tms_utime; /* user time */
61 clock_t tms_stime; /* system time */
62 clock_t tms_cutime; /* user time of children */
63 clock_t tms_cstime; /* system time of children */
70 field contains the CPU time spent executing instructions
71 of the calling process.
74 field contains the CPU time spent in the system while
75 executing tasks on behalf of the calling process.
78 field contains the sum of the
82 values for all waited-for terminated children.
85 field contains the sum of the
89 values for all waited-for terminated children.
91 Times for terminated children (and their descendants)
92 is added in at the moment
96 returns their process ID.
97 In particular, times of grandchildren
98 that the children did not wait for are never seen.
100 All times reported are in clock ticks.
103 returns the number of clock ticks that have elapsed since
104 an arbitrary point in the past.
105 For Linux 2.4 and earlier this point is the moment the system was booted.
106 Since Linux 2.6, this point is \fI(2^32/HZ) \- 300\fP
107 (i.e., about 429 million) seconds before system boot time.
108 The return value may overflow the possible range of type
110 On error, \fI(clock_t) \-1\fP is returned, and
112 is set appropriately.
114 The number of clock ticks per second can be obtained using
116 sysconf(_SC_CLK_TCK);
118 In POSIX-1996 the symbol CLK_TCK (defined in
120 is mentioned as obsolescent.
123 In Linux kernel versions before 2.6.9,
124 if the disposition of
128 then the times of terminated children
129 are automatically included in the
133 fields, although POSIX.1-2001 says that this should only happen
134 if the calling process
137 This non-conformance is rectified in Linux 2.6.9 and later.
138 .\" See the description of times() in XSH, which says:
139 .\" The times of a terminated child process are included... when wait()
140 .\" or waitpid() returns the process ID of this terminated child.
144 argument can be specified as NULL, with the result that
146 just returns a function result.
147 However, POSIX does not specify this behaviour, and most
148 other Unix implementations require a non-NULL value for
153 returns values of type
155 that are not measured in clock ticks
159 SVr4, 4.3BSD, POSIX.1-2001.
160 .SH "HISTORICAL NOTES"
163 and the struct members are of type
165 although they store clock ticks, not seconds since the epoch.
168 for the struct members, because it had no type
172 On older systems the number of clock ticks per second is given