sigvec(3)

✨ sigvec(3) β€” the BSD signal API, aka the vintage collection πŸ’…

okay bestie settle in, because we're about to talk about a section 3 library page and it's giving "grandma's attic but make it signals" πŸŽ€


🌸 NAME 🌸

sigvec, sigblock, sigsetmask, siggetmask, sigmask β€” the BSD signal API. yes, all of them. one big friend group. πŸ‘‘


πŸ“š LIBRARY πŸ“š

Standard C library (libc, -lc). the classic. the default. the one that's just there. πŸ’–


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <signal.h>

[[deprecated]] int sigvec(int sig, const struct sigvec *vec,
                          struct sigvec *ovec);

[[deprecated]] int sigmask(int signum);

[[deprecated]] int sigblock(int mask);
[[deprecated]] int sigsetmask(int mask);
[[deprecated]] int siggetmask(void);

πŸ” Feature Test Macro Requirements for glibc (see feature_test_macros(7)):

All functions shown above:

  • Since glibc 2.19:
    • _DEFAULT_SOURCE
  • glibc 2.19 and earlier:
    • _BSD_SOURCE
see that [[deprecated]]? yeah. the compiler is side-eyeing you. it's not a vibe check you pass, it's a vibe check you fail πŸ’€

πŸ’œ DESCRIPTION πŸ’œ

So glibc keeps these functions around as a compatibility interface for programs that use the historical BSD signal API. That's the key thing: this API is obsolete, and new applications should be using the POSIX signal API instead β€” sigaction(2), sigprocmask(2), etc. respectfully, move on bestie. 🫢

sigvec() β€” the main character ✨

sigvec() sets and/or gets the disposition of the signal sig (like the POSIX sigaction(2) does).

  • If vec is not NULL, it points to a sigvec structure that defines the new disposition for sig.
  • If ovec is not NULL, it points to a sigvec structure that is used to return the previous disposition of sig.

Want to just peek at the current disposition of sig without touching anything? Specify NULL for vec, and a non-null pointer for ovec. no notes, just looking. πŸ‘€

The dispositions for SIGKILL and SIGSTOP cannot be changed. nope. not happening. not today. not ever. those two are locked in and the key got thrown in the ocean 🌊

The sigvec structure has the following form:

struct sigvec {
    void (*sv_handler)(int); /* Signal disposition */
    int    sv_mask;          /* Signals to be blocked in handler */
    int    sv_flags;         /* Flags */
};

the fields, one by one πŸŽ€

  • sv_handler β€” specifies the disposition of the signal, and is either: the address of a signal handler function; SIG_DFL, meaning the default disposition applies for the signal; or SIG_IGN, meaning that the signal is ignored.
  • sv_mask β€” if sv_handler specifies the address of a signal handler, then sv_mask specifies a mask of signals that are to be blocked while the handler is executing. In addition, the signal for which the handler is invoked is also blocked. Attempts to block SIGKILL or SIGSTOP are silently ignored. (see? told you. unbothered. unbothered. totally unbothered πŸ’…)
  • sv_flags β€” if sv_handler specifies the address of a signal handler, then sv_flags specifies flags controlling what happens when the handler is called. This field may contain zero or more of the following flags:

SV_INTERRUPT 🌈

If the signal handler interrupts a blocking system call, then upon return from the handler the system call is not restarted: instead it fails with the error EINTR. If this flag is not specified, then system calls are restarted by default.

SV_RESETHAND 🌸

Reset the disposition of the signal to the default before calling the signal handler. If this flag is not specified, then the handler remains established until explicitly removed by a later call to sigvec() or until the process performs an execve(2).

SV_ONSTACK πŸ¦‹

Handle the signal on the alternate signal stack (historically established under BSD using the obsolete sigstack() function; the POSIX replacement is sigaltstack(2)).

sigmask() ✨

The sigmask() macro constructs and returns a "signal mask" for signum. For example, we can initialize the vec.sv_mask field given to sigvec() using code such as the following:

vec.sv_mask = sigmask(SIGQUIT) | sigmask(SIGABRT);
            /* Block SIGQUIT and SIGABRT during
               handler execution */

look at that bitwise OR. that's literally her. the way she composes a mask 😭πŸ”₯

sigblock() πŸ’–

The sigblock() function adds the signals in mask to the process's signal mask (like POSIX sigprocmask(SIG_BLOCK)), and returns the process's previous signal mask. Attempts to block SIGKILL or SIGSTOP are silently ignored. (again. iconic behaviour honestly.)

sigsetmask() πŸ‘‘

The sigsetmask() function sets the process's signal mask to the value given in mask (like POSIX sigprocmask(SIG_SETMASK)), and returns the process's previous signal mask.

siggetmask() πŸ“

The siggetmask() function returns the process's current signal mask. This call is equivalent to sigblock(0).


⭐ RETURN VALUE ⭐

  • sigvec() returns 0 on success; on error, it returns -1 and sets errno to indicate the error. classic. very demure. very mindful.
  • sigblock() and sigsetmask() return the previous signal mask.
  • sigmask() returns the signal mask for signum.

πŸ’€ ERRORS πŸ’€

See the ERRORS under sigaction(2) and sigprocmask(2). we're outsourcing. delegation is self-care fr fr.


🌟 ATTRIBUTES 🌟

For an explanation of the terms used in this section, see attributes(7).

  • sigvec(), sigmask(), sigblock(), sigsetmask(), siggetmask() β€” Thread safety β€” MT-Safe πŸŽ‰

🌈 STANDARDS 🌈

None. not a single one. she's unstandardised. she's free. she answers to no committee 😌


πŸ“œ HISTORY πŸ“œ

  • sigvec(), sigblock(), sigmask(), sigsetmask() β€” 4.3BSD.
  • siggetmask() β€” Unclear origin. mystery girl. we don't know where she came from and honestly? we respect it πŸ™ˆ
  • sigvec() β€” Removed in glibc 2.21. gone. departed. no forwarding address. (the others still linger though, bestie)

🧚 NOTES 🧚

On 4.3BSD, the signal() function provided reliable semantics (as when calling sigvec() with vec.sv_mask equal to 0). On System V, signal() provides unreliable semantics. POSIX.1 leaves these aspects of signal() unspecified. See signal(2) for further details.

In order to wait for a signal, BSD and System V both provided a function named sigpause(3), but this function has a different argument on the two systems. See sigpause(3) for details.

same name, different argument, two systems β€” it's giving messy family drama and we're NOT getting involved 🍿

πŸ”₯ SEE ALSO πŸ”₯

kill(2), pause(2), sigaction(2), signal(2), sigprocmask(2), raise(3), sigpause(3), sigset(3), signal(7)


and that's the whole page bestie, no cap πŸ’…βœ¨ this little gem is straight outta Linux man-pages 6.20, dated 2026-02-08. go forth and use sigaction(2) instead, ok? love u byeee πŸ«ΆπŸ’–πŸŽ€

πŸ“¦ 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