GETITIMER(3P)
β¨ GETITIMER(3P) β POSIX Programmer's Manual β¨
okay bestie, welcome to the POSIX Programmer's Manual π this one's getitimer / setitimer, aka your interval-timer besties.
β οΈ real talk first: this manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (so go check the corresponding Linux manual page for the deets on Linux behavior), or the interface may not be implemented on Linux at all. π
π NAME π
getitimer, setitimer β get and set value of interval timer
πΈ SYNOPSIS πΈ
#include <sys/time.h>
int getitimer(int which, struct itimerval *value);
int setitimer(int which, const struct itimerval *restrict value,
struct itimerval *restrict ovalue);
π DESCRIPTION π
so getitimer() shall store the current value of the timer specified by which into the structure pointed to by value. π«Ά
and setitimer() shall set the timer specified by which to the value specified in the structure pointed to by value, and β if ovalue is not a null pointer β store the previous value of the timer in the structure pointed to by ovalue. iconic behavior, honestly.
A timer value is defined by the itimerval structure, specified in <sys/time.h>. Here's the vibe check on its fields:
- if
it_valueis non-zero, it shall indicate the time to the next timer expiration. - if
it_intervalis non-zero, it shall specify a value to be used in reloadingit_valuewhen the timer expires. - setting
it_valueto0shall disable a timer, regardless of the value ofit_interval. - setting
it_intervalto0shall disable a timer after its next expiration (assumingit_valueis non-zero).
Implementations may place limitations on the granularity of timer values. For each interval timer, if the requested timer value requires a finer granularity than the implementation supports, the actual timer value shall be rounded up to the next supported value. (no half-measures, it rounds up π)
An XSI-conforming implementation provides each process with at least three interval timers, which are indicated by the which argument:
ITIMER_PROFβ decrements both in process virtual time and when the system is running on behalf of the process. It is designed to be used by interpreters in statistically profiling the execution of interpreted programs. Each time theITIMER_PROFtimer expires, theSIGPROFsignal is delivered. π§ITIMER_REALβ decrements in real time. ASIGALRMsignal is delivered when this timer expires. β°ITIMER_VIRTUALβ decrements in process virtual time. It runs only when the process is executing. ASIGVTALRMsignal is delivered when it expires. π
π¨ the interaction betweensetitimer()andalarm()orsleep()is unspecified. like, genuinely undefined bestie, do not test it.
β RETURN VALUE β
Upon successful completion, getitimer() or setitimer() shall return 0; otherwise, -1 shall be returned and errno set to indicate the error. classic.
π₯ ERRORS π₯
The setitimer() function shall fail if:
EINVALβ thevalueargument is not in canonical form. (In canonical form, the number of microseconds is a non-negative integer less than1000000and the number of seconds is a non-negative integer.) π
The getitimer() and setitimer() functions may fail if:
EINVALβ thewhichargument is not recognized.
The following sections are informative. π
π¦ EXAMPLES π¦
None. (yeah, zero. nothing. the void. π)
π APPLICATION USAGE π
Applications should use the timer_gettime() and timer_settime() functions instead of the obsolescent getitimer() and setitimer() functions, respectively. lowkey a glow-up recommendation β the old ones are obsolescent, so move on bestie. π
π RATIONALE π
None.
π FUTURE DIRECTIONS π
The getitimer() and setitimer() functions may be removed in a future version. π so likeβ¦ don't get too attached.
π SEE ALSO π
alarm(),exec,sleep(),timer_getoverrun()
The Base Definitions volume of POSIX.1β2017, <signal.h>, <sys_time.h>
π COPYRIGHT π
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .
Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .
and that's the whole page, bestie π«Ά written by IEEE/The Open Group, dated 2017 β go off, you now know your interval timers fr fr. periodt. π β¨
π¦ where this page comes from
- alpine 3.22: man-pages-posix 2017a-r0 Β· custom
- alpine 3.23: man-pages-posix 2017a-r0 Β· custom
- alpine 3.24: man-pages-posix 2017a-r0 Β· custom
- arch rolling: man-pages 6.19-1
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages-posix 2017a
- opensuse-leap 16.0: man-pages-posix 2017a-160000.4.1 Β· SUSE-IEEE
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms