ALARM(3)
π NAME π
okay so bestie, welcome to alarm(3) from the Library Functions Manual π β this one is literally about setting a signal timer alarm. No cap, that's the whole vibe: alarm = set signal timer alarm. π
π LIBRARY π
Standard C Library (libc, -lc) β that's where this lives, periodt. π«Ά
β¨ SYNOPSIS β¨
#include <unistd.h>
unsigned int
alarm(unsigned int seconds);
π DESCRIPTION π
β οΈ warning vibes: this interface is made obsolete by setitimer(2).
not me having to say that first π β like, it's still here, but setitimer(2) is the one that made it obsolete. Keep that in mind, fr fr.
The alarm() function sets a timer to deliver the signal SIGALRM to the calling process after the specified number of seconds. β°π₯
If an alarm has already been set with alarm() but has not been delivered, another call to alarm() will supersede the prior call. So yeah, the new one takes over β the old one doesn't get a second chance. π
The request alarm(0) voids the current alarm and the signal SIGALRM will not be delivered. Zero means cancel, bestie β no signal, no drama. π«π
Due to setitimer(2) restriction the maximum number of seconds allowed is 100,000,000. That's the ceiling, okay? Don't try to be extra with a bigger number. π
π RETURN VALUES π
The return value of alarm() is the amount of time left on the timer from a previous call to alarm(). So it's like, βhey, here's what was left from last time.β π°οΈ
If no alarm is currently set, the return value is 0. Lowkey simple. β¨
π SEE ALSO π
setitimer(2), sigaction(2), sigsuspend(2), signal(3), sleep(3), ualarm(3), usleep(3) β go read these too, bestie, iykyk. π
π¦ HISTORY π¦
An alarm() system call appeared in the Programmer's Workbench (PWB/UNIX) and was ported to Version 7 AT&T UNIX. So it's giving ancient Unix lore. ποΈ
For 4.1cBSD, it was reimplemented as a wrapper around the setitimer(2) system call. And that's the glow-up, no cap. β¨
this lil page is from Debian's ALARM(3), dated April 2, 2022 β mwah, hope that helped bestie ππ«Ά
π¦ where this page comes from
- freebsd 15.1: base 15.1
- Copyright (c) 1980, 1991, 1993, 1994 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