sigwait(3)
โจ sigwait(3) โจ
okay bestie so this is a page from the Library Functions Manual, and it's all about sigwait โ literally the function that just chills until a signal shows up. ๐ yes, we're doing signals today, and no cap it's gonna be fun.
๐ธ NAME ๐ธ
sigwait โ wait for a signal
like. that's it. that's the whole job. sit there and wait. main character energy honestly. ๐
๐ LIBRARY ๐
Standard C library (libc, -lc)
โจ SYNOPSIS โจ
#include <signal.h>
int sigwait(const sigset_t *restrict set, int *restrict sig);
๐ฆ Feature Test Macro Requirements for glibc ๐ฆ
(peek feature_test_macros(7) if you're lost, bestie)
sigwait():
- Since glibc 2.26:
_POSIX_C_SOURCE >= 199506L
- glibc 2.25 and earlier:
_POSIX_C_SOURCE
๐ DESCRIPTION ๐
So here's the tea. ๐ต The sigwait() function suspends execution of the calling thread until one of the signals in the signal set set becomes pending. Just... paused. Waiting. Iconic.
BUT. And this is the part everyone forgets: for a signal to even become pending in the first place, it has to be blocked first with sigprocmask(2). Blocked, then pending, then sigwait() catches it. Order matters, bestie, don't skip steps. ๐
Then the function accepts the signal โ which means it removes it from the pending list of signals โ and hands you back the signal number in sig. ๐ซถ
Also, lowkey important: the operation of sigwait() is the same as sigwaitinfo(2), except for these two things:
sigwait()returns only the signal number, rather than asiginfo_tstructure describing the signal. no extra lore, just the number.- The return values of the two functions are different. yes really. don't get cute and swap them.
๐ฅ RETURN VALUE ๐ฅ
- On success,
sigwait()returns 0. slay. โจ - On error, it returns a positive error number (the ones listed down in ERRORS, babes).
๐ ERRORS ๐
EINVALโsetcontains an invalid signal number. like, that's not a real signal, girl. ๐
๐ ATTRIBUTES ๐
For an explanation of the terms used in this section, see attributes(7).
- Interface:
sigwait() - Attribute: Thread safety
- Value:
MT-Safe
MT-Safe!! multi-thread safe!! she's responsible AND fun. ๐
๐ VERSIONS ๐
sigwait()is implemented usingsigtimedwait(2); go consult its NOTES if you want the behind-the-scenes.- The glibc implementation of
sigwait()silently ignores attempts to wait for the two real-time signals that are used internally by the NPTL threading implementation. she just pretends she didn't hear you. ๐ Seenptl(7)for details.
โญ STANDARDS โญ
POSIX.1-2008.
๐ง HISTORY ๐ง
POSIX.1-2001.
she's been here a while. veteran queen. ๐
๐ EXAMPLES ๐
See pthread_sigmask(3).
๐ SEE ALSO ๐
sigaction(2), signalfd(2), sigpending(2), sigsuspend(2), sigwaitinfo(2), sigsetops(3), signal(7)
fr fr, don't forget the block-first step. sigwait() is not gonna magically receive a signal you never blocked. that's not a vibe check she passes. ๐
anyway that's the whole page!! this one's from Linux man-pages 6.20, dated 2025-05-17, and if you need me I'll be over here waiting for a signal like sigwait(3) herself. bye bestie, go slay some signal handling ๐
โจ๐ฆ
๐ฆ 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: Linux-man-pages-copyleft
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms