TIMES(3)
β¨ TIMES(3) β the process times glow-up β¨
okay bestie, so this is the times(3) manual page from the Standard C Library, and we're gonna get into it π
no cap.
π·οΈ NAME
times β process times (yes that's the whole name, she's lowkey mysterious like that)
π LIBRARY
Standard C Library, aka libc, linked with -lc β the icon herself π«Ά
π SYNOPSIS
#include <sys/times.h>
clock_t
times(struct tms *tp);
π DESCRIPTION
okay so first thing's first: this interface is obsoleted by getrusage(2) and gettimeofday(2). like, she's giving legacy energy, but she still ate and we respect her π
The times() function returns the value of time in CLK_TCK's of a second since the system startup time. and the current value of CLK_TCK β which is the frequency of the statistics clock in ticks per second β you can get that through the sysconf(3) interface, iykyk πΈ
It also fills in the structure pointed to by tp with time-accounting information. not me being obsessed with a struct that just... holds time data π
The tms structure is defined as follows β and yes, we're copying it exactly, periodt:
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 (main character energy per field):
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 thetms_utimesandtms_cutimesof the child processes πtms_cstimeβ the sum of thetms_stimesandtms_cstimesof the child processes π
all times are in CLK_TCK's of a second, no exceptions π
and here's the vibe on terminated child processes: 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. so like, the parent gets the credit for the child's work when the child exits β it's giving nepotism but make it syscalls π
if an error occurs, times() returns the value ((clock_t)-1), and sets errno to indicate the error. so bestie, if you see (clock_t)-1, that's your red flag π© and errno is the receipt.
π¨ 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). so like, don't come for times() directly β she's just forwarding you to her friends who actually handle the error details π
π SEE ALSO
time(1)β bestie's older sistergetrusage(2)β the replacement (and honestly, the upgrade)gettimeofday(2)β the other replacement, equally iconicwait(2)β the one that makes child process times appearsysconf(3)β how you getCLK_TCK, no gatekeepingclocks(7)β the lore deep-dive on clocks in general
π STANDARDS
The times() function conforms to IEEE Std 1003.1-1988 (βPOSIX.1β). she's certified, she's historic, she's giving old-money POSIX energy π
π‘ quick vibe check: this function is obsoleted β meaning don't build new stuff on it, bestie. usegetrusage(2)orgettimeofday(2)instead. but if you're maintaining old code, now you get her π«Ά
alright that's the whole page, no notes π
this was the TIMES(3) manual from the Debian crew β page dated December 1, 2008, and like yeah it's old but she still slays β¨ππ¦
π¦ where this page comes from
- freebsd 15.1: base 15.1
- Copyright (c) 1990, 1991, 1993 The Regents of the University of California. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms