ualarm(3)
π ualarm(3) β the library functions manual, but make it cute
okay bestie, welcome to ualarm(3), a lil function from the Library Functions Manual whose whole job is schedule signal after given number of microseconds. she's giving alarm clock energy but make it micro. π
β¨ NAME β¨
ualarm β schedule signal after given number of microseconds β°
π LIBRARY π
Standard C library (libc, -lc) π
πΈ SYNOPSIS πΈ
#include <unistd.h>
useconds_t ualarm(useconds_t usecs, useconds_t interval);
π§ Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
ualarm():
Since glibc 2.12:
(_XOPEN_SOURCE >= 500) && ! (_POSIX_C_SOURCE >= 200809L)
|| /* glibc >= 2.19: */ _DEFAULT_SOURCE
|| /* glibc <= 2.19: */ _BSD_SOURCE
Before glibc 2.12:
_BSD_SOURCE || _XOPEN_SOURCE >= 500
ngl the feature test macro section is the group chat you have to be in before you're even allowed to @ her. define the right macros or she's not answering, periodt. π
π« DESCRIPTION π«
so ualarm() sends the signal SIGALRM to the process that called it, after (and not less than) usecs microseconds. not exactly usecs though bestie β that delay can get lengthened slightly by any system activity, or by the time spent processing the call itself, or by the granularity of system timers. so like, she's punctual but she's also a whole system, you know?
and unless it's caught or ignored, the SIGALRM signal will terminate the process. π like, no warning, no soft launch, just gone.
if the interval argument is nonzero, further SIGALRM signals keep getting sent every interval microseconds after the first one. she's not a one-time thing, she's recurring. π¦
π₯ RETURN VALUE π₯
she returns the number of microseconds remaining for any alarm that was previously set β or 0 if no alarm was pending. so you can lowkey find out how much snooze time was left on the old one. β³
π ERRORS π
EINTRβ interrupted by a signal; seesignal(7). she got distracted, rude of whatever signal did that.EINVALβusecsorintervalis not smaller than1000000. (on systems where that is considered an error.) so don't be out here requesting more than a second in a function literally named micro. π
π ATTRIBUTES π
for an explanation of the terms used in this section, see attributes(7).
ualarm()β Thread safety:MT-Safeβ¨
she is MT-Safe, which is the bare minimum we ask for in a friend. π«Ά
π STANDARDS π
None. literally none. she's unstandardised, she's free, she's an icon. π
π HISTORY π
4.3BSD, POSIX.1-2001. and listen β POSIX.1-2001 marks it as obsolete. removed in POSIX.1-2008. so yeah, she's vintage. π°οΈ
4.3BSD, SUSv2, and POSIX do not define any errors. the error list above? that's bonus content.
POSIX.1-2001 does not specify what happens if the usecs argument is 0. on Linux (and probably most other systems), the effect is to cancel any pending alarm. so 0 is the "never mind, cancel that" button. π
the type useconds_t is an unsigned integer type capable of holding integers in the range [0,1000000]. on the original BSD implementation, and in glibc before glibc 2.1, the arguments to ualarm() were instead typed as unsigned int. programs will be more portable if they never mention useconds_t explicitly β so like, just don't name-drop her, that's the move.
the interaction of this function with other timer functions such as alarm(2), sleep(3), nanosleep(2), setitimer(2), timer_create(2), timer_delete(2), timer_getoverrun(2), timer_gettime(2), timer_settime(2), usleep(3) is unspecified. β οΈ unspecified meaning nobody promised you anything, so don't come crying when it goes feral.
π¨ REAL TALK: this function is obsolete. usesetitimer(2)or POSIX interval timers (timer_create(2), etc.) instead. like genuinely bestie, she's a legacy pick, ship the newer ones. π
π SEE ALSO π
alarm(2), getitimer(2), nanosleep(2), select(2), setitimer(2), usleep(3), time(7)
and that's the whole page, no notes. this one's from Linux man-pages 6.20, dated 2026-02-08, and that's your ualarm(3) moment right there. slay, stay timed, and don't use obsolete functions in production, mwah πβ¨π
π¦ where this page comes from
- 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 6.20
- π the page's license: GPL-2.0-or-later
- Copyright 2003, Andries E. Brouwer <aeb@cwi.nl>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms