]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/times.2
Fix redundant formatting macros
[thirdparty/man-pages.git] / man2 / times.2
CommitLineData
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
40times \- 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
47stores the current process times in the
48.I "struct tms"
fea681da 49that
0daa9e92 50.I buf
fea681da
MK
51points to.
52The
53.I struct tms
54is as defined in
55.IR <sys/times.h> :
56.sp
d4c46761 57.in +0.5i
fea681da
MK
58.nf
59struct 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
68The
69.I tms_utime
70field contains the CPU time spent executing instructions
71of the calling process.
72The
73.I tms_stime
74field contains the CPU time spent in the system while
75executing tasks on behalf of the calling process.
76The
77.I tms_cutime
78field contains the sum of the
79.I tms_utime
80and
81.I tms_cutime
82values for all waited-for terminated children.
83The
84.I tms_cstime
85field contains the sum of the
86.I tms_stime
87and
88.I tms_cstime
89values for all waited-for terminated children.
90.LP
91Times for terminated children (and their descendants)
92is added in at the moment
93.BR wait (2)
94or
95.BR waitpid (2)
c13182ef
MK
96returns their process ID.
97In particular, times of grandchildren
fea681da
MK
98that the children did not wait for are never seen.
99.LP
100All times reported are in clock ticks.
101.SH "RETURN VALUE"
4c926acf 102.BR times ()
fea681da 103returns the number of clock ticks that have elapsed since
e263839c
MK
104an arbitrary point in the past.
105For Linux 2.4 and earlier this point is the moment the system was booted.
e9496f74 106Since 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 108The return value may overflow the possible range of type
a5e0a0e4 109.IR clock_t .
4c926acf 110On error, \fI(clock_t) \-1\fP is returned, and
fea681da
MK
111.I errno
112is set appropriately.
74fa514a 113.\" The only possible error is EFAULT.
2dd578fd
MK
114.SH "CONFORMING TO"
115SVr4, 4.3BSD, POSIX.1-2001.
fea681da 116.SH NOTES
f3fef736 117The number of clock ticks per second can be obtained using:
fea681da 118.RS
f3fef736 119
fea681da
MK
120sysconf(_SC_CLK_TCK);
121.RE
f3fef736
MK
122.PP
123In POSIX.1-1996 the symbol \fBCLK_TCK\fP (defined in
fea681da 124.IR <time.h> )
c13182ef
MK
125is mentioned as obsolescent.
126It is obsolete now.
fea681da 127.PP
81841f39 128In Linux kernel versions before 2.6.9,
4c926acf
MK
129if the disposition of
130.B SIGCHLD
131is set to
fea681da
MK
132.B SIG_IGN
133then the times of terminated children
134are automatically included in the
135.I tms_cstime
136and
137.I tms_cutime
97c1eac8 138fields, although POSIX.1-2001 says that this should only happen
fea681da 139if the calling process
0bfa087b 140.BR wait (2)s
fea681da 141on its children.
81841f39 142This 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
147On Linux, the
148.I buf
149argument can be specified as NULL, with the result that
150.BR times ()
151just returns a function result.
d9bfdb9c 152However, POSIX does not specify this behavior, and most
b6ac5354
MK
153other Unix implementations require a non-NULL value for
154.IR buf .
fea681da
MK
155.LP
156Note that
157.BR clock (3)
4c926acf
MK
158returns values of type
159.I clock_t
160that are not measured in clock ticks
161but in
162.BR CLOCKS_PER_SEC .
8c87824d
MK
163.PP
164On older systems the number of clock ticks per second is given
165by the variable HZ.
166.SS "Historical"
fea681da 167SVr1-3 returns
4c926acf 168.I long
fea681da 169and the struct members are of type
4c926acf 170.I time_t
c13182ef
MK
171although they store clock ticks, not seconds since the epoch.
172V7 used
4c926acf 173.I long
fea681da 174for the struct members, because it had no type
4c926acf 175.I time_t
fea681da 176yet.
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)