ALARM(3)

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

🌈 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
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms