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 a siginfo_t structure 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 โ€” set contains 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 using sigtimedwait(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. ๐Ÿ™ˆ See nptl(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