]>
Commit | Line | Data |
---|---|---|
fea681da MK |
1 | .\" Hey Emacs! This file is -*- nroff -*- source. |
2 | .\" | |
3 | .\" Copyright (c) 1992 Drew Eckhardt (drew@cs.colorado.edu), March 28, 1992 | |
4 | .\" | |
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. | |
8 | .\" | |
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. | |
c13182ef | 13 | .\" |
fea681da MK |
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 | |
20 | .\" professionally. | |
c13182ef | 21 | .\" |
fea681da MK |
22 | .\" Formatted or processed versions of this manual, if unaccompanied by |
23 | .\" the source, must acknowledge the copyright and authors of this work. | |
24 | .\" | |
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) | |
c11b1abf | 29 | .\" Modified 13 Jun 02, Michael Kerrisk <mtk.manpages@gmail.com> |
d9bfdb9c | 30 | .\" Added note on non-standard behavior when SIGCHLD is ignored. |
4c926acf MK |
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 | |
e263839c | 33 | .\" Modified 2004-12-08, mtk, in 2.6 times() return value changed |
b6ac5354 | 34 | .\" 2005-04-13, mtk |
d9bfdb9c | 35 | .\" Added notes on non-standard behavior: Linux allows 'buf' to |
b6ac5354 | 36 | .\" be NULL, but POSIX.1 doesn't specify this and it's non-portable. |
fea681da MK |
37 | .\" |
38 | .TH TIMES 2 2002-06-14 "Linux" "Linux Programmer's Manual" | |
39 | .SH NAME | |
40 | times \- get process times | |
41 | .SH SYNOPSIS | |
42 | .B #include <sys/times.h> | |
43 | .sp | |
44 | .BI "clock_t times(struct tms *" buf ); | |
45 | .SH DESCRIPTION | |
fea681da | 46 | .BR times () |
4c926acf MK |
47 | stores the current process times in the |
48 | .I "struct tms" | |
fea681da | 49 | that |
0daa9e92 | 50 | .I buf |
fea681da MK |
51 | points to. |
52 | The | |
53 | .I struct tms | |
54 | is as defined in | |
55 | .IR <sys/times.h> : | |
56 | .sp | |
d4c46761 | 57 | .in +0.5i |
fea681da MK |
58 | .nf |
59 | struct tms { | |
e81969ab MK |
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 */ | |
fea681da MK |
64 | }; |
65 | .fi | |
d4c46761 | 66 | .in |
fea681da MK |
67 | .LP |
68 | The | |
69 | .I tms_utime | |
70 | field contains the CPU time spent executing instructions | |
71 | of the calling process. | |
72 | The | |
73 | .I tms_stime | |
74 | field contains the CPU time spent in the system while | |
75 | executing tasks on behalf of the calling process. | |
76 | The | |
77 | .I tms_cutime | |
78 | field contains the sum of the | |
79 | .I tms_utime | |
80 | and | |
81 | .I tms_cutime | |
82 | values for all waited-for terminated children. | |
83 | The | |
84 | .I tms_cstime | |
85 | field contains the sum of the | |
86 | .I tms_stime | |
87 | and | |
88 | .I tms_cstime | |
89 | values for all waited-for terminated children. | |
90 | .LP | |
91 | Times for terminated children (and their descendants) | |
92 | is added in at the moment | |
93 | .BR wait (2) | |
94 | or | |
95 | .BR waitpid (2) | |
c13182ef MK |
96 | returns their process ID. |
97 | In particular, times of grandchildren | |
fea681da MK |
98 | that the children did not wait for are never seen. |
99 | .LP | |
100 | All times reported are in clock ticks. | |
101 | .SH "RETURN VALUE" | |
4c926acf | 102 | .BR times () |
fea681da | 103 | returns the number of clock ticks that have elapsed since |
e263839c MK |
104 | an arbitrary point in the past. |
105 | For Linux 2.4 and earlier this point is the moment the system was booted. | |
e9496f74 | 106 | Since Linux 2.6, this point is \fI(2^32/HZ) \- 300\fP |
540036b2 | 107 | (i.e., about 429 million) seconds before system boot time. |
e263839c | 108 | The return value may overflow the possible range of type |
a5e0a0e4 | 109 | .IR clock_t . |
4c926acf | 110 | On error, \fI(clock_t) \-1\fP is returned, and |
fea681da MK |
111 | .I errno |
112 | is set appropriately. | |
74fa514a | 113 | .\" The only possible error is EFAULT. |
2dd578fd MK |
114 | .SH "CONFORMING TO" |
115 | SVr4, 4.3BSD, POSIX.1-2001. | |
fea681da | 116 | .SH NOTES |
f3fef736 | 117 | The number of clock ticks per second can be obtained using: |
fea681da | 118 | .RS |
f3fef736 | 119 | |
fea681da MK |
120 | sysconf(_SC_CLK_TCK); |
121 | .RE | |
f3fef736 MK |
122 | .PP |
123 | In POSIX.1-1996 the symbol \fBCLK_TCK\fP (defined in | |
fea681da | 124 | .IR <time.h> ) |
c13182ef MK |
125 | is mentioned as obsolescent. |
126 | It is obsolete now. | |
fea681da | 127 | .PP |
81841f39 | 128 | In Linux kernel versions before 2.6.9, |
4c926acf MK |
129 | if the disposition of |
130 | .B SIGCHLD | |
131 | is set to | |
fea681da MK |
132 | .B SIG_IGN |
133 | then the times of terminated children | |
134 | are automatically included in the | |
135 | .I tms_cstime | |
136 | and | |
137 | .I tms_cutime | |
97c1eac8 | 138 | fields, although POSIX.1-2001 says that this should only happen |
fea681da | 139 | if the calling process |
0bfa087b | 140 | .BR wait (2)s |
fea681da | 141 | on its children. |
81841f39 | 142 | This non-conformance is rectified in Linux 2.6.9 and later. |
fea681da MK |
143 | .\" See the description of times() in XSH, which says: |
144 | .\" The times of a terminated child process are included... when wait() | |
704a18f0 | 145 | .\" or waitpid() returns the process ID of this terminated child. |
b6ac5354 MK |
146 | |
147 | On Linux, the | |
148 | .I buf | |
149 | argument can be specified as NULL, with the result that | |
150 | .BR times () | |
151 | just returns a function result. | |
d9bfdb9c | 152 | However, POSIX does not specify this behavior, and most |
b6ac5354 MK |
153 | other Unix implementations require a non-NULL value for |
154 | .IR buf . | |
fea681da MK |
155 | .LP |
156 | Note that | |
157 | .BR clock (3) | |
4c926acf MK |
158 | returns values of type |
159 | .I clock_t | |
160 | that are not measured in clock ticks | |
161 | but in | |
162 | .BR CLOCKS_PER_SEC . | |
8c87824d MK |
163 | .PP |
164 | On older systems the number of clock ticks per second is given | |
165 | by the variable HZ. | |
166 | .SS "Historical" | |
fea681da | 167 | SVr1-3 returns |
4c926acf | 168 | .I long |
fea681da | 169 | and the struct members are of type |
4c926acf | 170 | .I time_t |
c13182ef MK |
171 | although they store clock ticks, not seconds since the epoch. |
172 | V7 used | |
4c926acf | 173 | .I long |
fea681da | 174 | for the struct members, because it had no type |
4c926acf | 175 | .I time_t |
fea681da | 176 | yet. |
fea681da MK |
177 | .SH "SEE ALSO" |
178 | .BR time (1), | |
179 | .BR getrusage (2), | |
180 | .BR wait (2), | |
181 | .BR clock (3), | |
eafd5ce1 MK |
182 | .BR sysconf (3), |
183 | .BR time (7) |