GETITIMER(3POSIX)
π GETITIMER(3POSIX) π
okay bestie, welcome to the POSIX Programmer's Manual β this is the getitimer page, and we're gonna get into it. π«Ά
πΈ PROLOG πΈ
so like, real talk first: this manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (if you're on Linux, go check the corresponding Linux manual page for the actual tea β), or honestly the interface might not even be implemented on Linux at all. π
β¨ NAME β¨
getitimer, setitimer β get and set value of interval timer. it's giving "clock management, but make it POSIX." π
π 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 the getitimer() function shall store the current value of the timer specified by which into the structure pointed to by value. simple. iconic. no notes. β¨
and setitimer()? it shall set the timer specified by which to the value specified in the structure pointed to by value, and β plot twist β if ovalue is not a null pointer, it stores the previous value of the timer in the structure pointed to by ovalue. so you get the receipts of what it was before. π§Ύπ
A timer value is defined by the itimerval structure, specified in <sys/time.h>. here's the breakdown:
- 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. (yes, regardless. it_value is the main character here π) - setting
it_intervalto0shall disable a timer after its next expiration (assumingit_valueis non-zero). so it gets one last hurrah. π€
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. so like, you ask for something tiny and precise, and the system rounds up. no down-rounding, bestie. π
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. π§
β οΈ okay warning time: the interaction betweensetitimer()andalarm()orsleep()is unspecified. so like, don't expect them to play nice together, bestie. that's undefined territory. π
π₯ RETURN VALUE π₯
Upon successful completion, getitimer() or setitimer() shall return 0. π
otherwise, -1 shall be returned and errno set to indicate the error. π
π 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.) like, get that struct in canonical form or it's not happening. π«
The getitimer() and setitimer() functions may fail if:
EINVALβ Thewhichargument is not recognized. (unknown timer? not on my watch. π)
The following sections are informative.
π EXAMPLES π
None.
(yeah. nothing. the vibes are immaculate but empty. π)
π¦ APPLICATION USAGE π¦
Applications should use the timer_gettime() and timer_settime() functions instead of the obsolescent getitimer() and setitimer() functions, respectively. π’ like bestie, these two are obsolescent β there's a newer, shinier way. use that instead, fr fr.
β RATIONALE β
None.
π FUTURE DIRECTIONS π
The getitimer() and setitimer() functions may be removed in a future version. so like... don't build your whole personality around them, iykyk. π
π SEE ALSO π
alarm()execsleep()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 .
okay that's the whole page bestie, you ate that π«Άβ¨ this was IEEE/The Open Group, 2017, page GETITIMER(3POSIX) β and that's a wrap, periodt. π
π
π¦ where this page comes from
- debian bookworm: manpages-posix-dev 2017a-2 Β· Other
- debian trixie: manpages-posix-dev 2017a-2 Β· Other
- ubuntu jammy: manpages-posix-dev 2017a-2 Β· Other
- ubuntu noble: manpages-posix-dev 2017a-2 Β· Other
- ubuntu resolute: manpages-posix-dev 2017a-2build1 Β· Other
- ubuntu stonking: manpages-posix-dev 2017a-2.1 Β· Other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms