SIGWAIT(2)
π SIGWAIT β select a set of signals π
okay bestie, welcome to SIGWAIT(2) from the System Calls Manual. this page is about picking a set of signals and waiting on them, and it is lowkey iconic. β¨
π NAME π
sigwait β select a set of signals. that's the name, bestie, and it's literally the whole point. π
π«Ά LIBRARY π«Ά
Standard C Library (libc, -lc) β she lives there. π«Ά
πΈ SYNOPSIS πΈ
#include <signal.h>
int
sigwait(const sigset_t * restrict set, int * restrict sig);
β¨ DESCRIPTION β¨
so the sigwait() system call selects a set of signals, and that set is specified by set. if none of the selected signals are pending, sigwait() waits until one or more of the selected signals has been generated. then sigwait() atomically clears one of the selected signals from the set of pending signals (for the process or for the current thread) and sets the location pointed to by sig to the signal number that was cleared. periodt. π
the signals specified by set should be blocked at the time of the call to sigwait(). yes, bestie, block them first β that's the vibe check. π«Ά
if more than one thread is using sigwait() to wait for the same signal, no more than one of these threads will return from sigwait() with the signal number. if more than a single thread is blocked in sigwait() for a signal when that signal is generated for the process, it is unspecified which of the waiting threads returns from sigwait(). if the signal is generated for a specific thread, as by pthread_kill(), only that thread will return. no cap. π₯
should any of the multiple pending signals in the range SIGRTMIN to SIGRTMAX be selected, it will be the lowest numbered one. the selection order between realtime and non-realtime signals, or between multiple pending non-realtime signals, is unspecified. so don't come for her about ordering unless the spec says so. π
π§ IMPLEMENTATION NOTES π§
the sigwait() function is implemented as a wrapper around the __sys_sigwait() system call, which retries the call on EINTR error. it's giving "try again, queen" energy. β¨
π RETURN VALUES π
if successful, sigwait() returns 0 and sets the location pointed to by sig to the cleared signal number. otherwise, an error number is returned. that's the whole flex. π
π ERRORS π
the sigwait() system call will fail if:
[EINVAL]β thesetargument specifies one or more invalid signal numbers. not the invalid signal numbers catching a case like that π
π¦ SEE ALSO π¦
sigaction(2), sigpending(2), sigqueue(2), sigsuspend(2), sigtimedwait(2), sigwaitinfo(2), pause(3), pthread_sigmask(3)
go read those too, bestie β iykyk. πβ¨
π STANDARDS π
the sigwait() function conforms to ISO/IEC 9945-1:1996 (βPOSIX.1β). slay. π
xoxo, Debian π β last touched September 6, 2013 β¨
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- Copyright (C) 2000 Jason Evans <jasone@FreeBSD.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms