]>
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) | |
305a0578 | 29 | .\" Modified 13 Jun 02, Michael Kerrisk <mtk-manpages@gmx.net> |
fea681da | 30 | .\" Added note on non-standard behaviour 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 MK |
34 | .\" 2005-04-13, mtk |
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. | |
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 MK |
49 | that |
50 | .IR buf | |
51 | points to. | |
52 | The | |
53 | .I struct tms | |
54 | is as defined in | |
55 | .IR <sys/times.h> : | |
56 | .sp | |
57 | .nf | |
58 | struct tms { | |
59 | .RS | |
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 */ | |
64 | .RE | |
65 | }; | |
66 | .fi | |
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. | |
113 | .SH NOTES | |
114 | The number of clock ticks per second can be obtained using | |
115 | .RS | |
116 | sysconf(_SC_CLK_TCK); | |
117 | .RE | |
118 | In POSIX-1996 the symbol CLK_TCK (defined in | |
119 | .IR <time.h> ) | |
c13182ef MK |
120 | is mentioned as obsolescent. |
121 | It is obsolete now. | |
fea681da | 122 | .PP |
81841f39 | 123 | In Linux kernel versions before 2.6.9, |
4c926acf MK |
124 | if the disposition of |
125 | .B SIGCHLD | |
126 | is set to | |
fea681da MK |
127 | .B SIG_IGN |
128 | then the times of terminated children | |
129 | are automatically included in the | |
130 | .I tms_cstime | |
131 | and | |
132 | .I tms_cutime | |
97c1eac8 | 133 | fields, although POSIX.1-2001 says that this should only happen |
fea681da MK |
134 | if the calling process |
135 | .BR wait ()s | |
136 | on its children. | |
81841f39 | 137 | This non-conformance is rectified in Linux 2.6.9 and later. |
fea681da MK |
138 | .\" See the description of times() in XSH, which says: |
139 | .\" The times of a terminated child process are included... when wait() | |
704a18f0 | 140 | .\" or waitpid() returns the process ID of this terminated child. |
b6ac5354 MK |
141 | |
142 | On Linux, the | |
143 | .I buf | |
144 | argument can be specified as NULL, with the result that | |
145 | .BR times () | |
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 | |
149 | .IR buf . | |
fea681da MK |
150 | .LP |
151 | Note that | |
152 | .BR clock (3) | |
4c926acf MK |
153 | returns values of type |
154 | .I clock_t | |
155 | that are not measured in clock ticks | |
156 | but in | |
157 | .BR CLOCKS_PER_SEC . | |
fea681da | 158 | .SH "CONFORMING TO" |
97c1eac8 | 159 | SVr4, 4.3BSD, POSIX.1-2001. |
fea681da MK |
160 | .SH "HISTORICAL NOTES" |
161 | SVr1-3 returns | |
4c926acf | 162 | .I long |
fea681da | 163 | and the struct members are of type |
4c926acf | 164 | .I time_t |
c13182ef MK |
165 | although they store clock ticks, not seconds since the epoch. |
166 | V7 used | |
4c926acf | 167 | .I long |
fea681da | 168 | for the struct members, because it had no type |
4c926acf | 169 | .I time_t |
fea681da MK |
170 | yet. |
171 | .PP | |
172 | On older systems the number of clock ticks per second is given | |
173 | by the variable HZ. | |
174 | .SH "SEE ALSO" | |
175 | .BR time (1), | |
176 | .BR getrusage (2), | |
177 | .BR wait (2), | |
178 | .BR clock (3), | |
eafd5ce1 MK |
179 | .BR sysconf (3), |
180 | .BR time (7) |