TIMES(3)

πŸ“¦
version 15.1 Β· 2 versions
, in freebsd 15.1

✨ 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 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, 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 sister
  • getrusage(2) β€” the replacement (and honestly, the upgrade)
  • gettimeofday(2) β€” the other replacement, equally iconic
  • wait(2) β€” the one that makes child process times appear
  • sysconf(3) β€” how you get CLK_TCK, no gatekeeping
  • clocks(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. use getrusage(2) or gettimeofday(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
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms