times(3)

times3

Process times

Usage

#include <sys/times.h>

clock_t

times(struct tms *tp);

Library

Standard C Library (libc, -lc)

Overview

This interface is obsoleted by getrusage(2) and gettimeofday(2).

The times() function returns the value of time in CLK_TCK's of a second since the system startup time. The current value of CLK_TCK, the frequency of the statistics clock in ticks per second, may be obtained through the sysconf(3) interface.

It also fills in the structure pointed to by tp with time-accounting information.

The tms structure is defined as follows:

struct tms {
	clock_t tms_utime;
	clock_t tms_stime;
	clock_t tms_cutime;
	clock_t tms_cstime;
};

The elements of this structure are defined as follows:

tms_utime

The CPU time charged for the execution of user instructions.

tms_stime

The CPU time charged for execution by the system on behalf of the process.

tms_cutime

The sum of the tms_utimes and tms_cutimes of the child processes.

tms_cstime

The sum of the tms_stimes and tms_cstimes of the child processes.

All times are in CLK_TCK's of a second.

The times of a terminated child process are included in the tms_cutime and tms_cstime elements of the parent when one of the wait(2) functions returns the process ID of the terminated child to the parent. If an error occurs, times() returns the value ((clock_t)-1), and sets errno to indicate the error.

Errors

The times() function may fail and set the global variable errno for any of the errors specified for the library routines getrusage(2) and gettimeofday(2).

Releases

87 releases since FreeBSD 2.0.5-RELEASE; the text changed 41 times.

  1. 2.0.5
  2. 2.1.5–3.4
  3. 3.5–3.5.1
  4. 4.0
  5. 4.1–4.2
  6. 4.3
  7. 4.4
  8. 4.5–4.11
  9. 5.0–6.3
  10. 6.4
  11. 7.0
  12. 7.1
  13. 7.2
  14. 7.3
  15. 7.4
  16. 8.0
  17. 8.1
  18. 8.2
  19. 8.3
  20. 8.4
  21. 9.0
  22. 9.1
  23. 9.2
  24. 9.3
  25. 10.0
  26. 10.1
  27. 10.2
  28. 10.3
  29. 10.4
  30. 11.0
  31. 11.1
  32. 11.2
  33. 11.3
  34. 11.4
  35. 12.0
  36. 12.1
  37. 12.2
  38. 12.3
  39. 12.4
  40. 13.0–13.2
  41. 13.3–14.5
  42. 15.0–16.0

Standards

The times() function conforms to IEEE Std 1003.1-1988 (“POSIX.1”).

From base 16.0-CURRENT-20261027-61c70dc16a79 in FreeBSD 16.0-CURRENT (2026-10-27). Parsed by carta from the page's mdoc source.