bsd_signal(3)

πŸ’– bsd_signal β€” bestie, it's signal handling but with BSD flavor πŸ’–

okay so you know signal(2)? this is that, but from the ✨BSD✨ side of the family. it lives in the Standard C library (libc, link that bad boy with -lc). let's get into it 🌸


✨ SYNOPSIS ✨

#include <signal.h>

typedef typeof(void (int))  *sighandler_t;

sighandler_t bsd_signal(int signum, sighandler_t handler);

πŸŽ€ Feature Test Macro Requirements for glibc (peep feature_test_macros(7) for the tea)

  • bsd_signal():
    • Since glibc 2.26:
_XOPEN_SOURCE >= 500
    && ! (_POSIX_C_SOURCE >= 200809L)
  • glibc 2.25 and earlier:
_XOPEN_SOURCE

🌈 DESCRIPTION 🌈

so bsd_signal() takes the exact same arguments and does the exact same job as signal(2). same energy, same task, no cap 🫢

the difference?? the whole difference, and it's lowkey the important part: bsd_signal() is guaranteed to give you reliable signal semantics. which means:

  1. the disposition of the signal is not reset to the default when the handler gets invoked πŸ™…
  2. delivery of further instances of the signal is blocked while the signal handler is executing πŸ”’
  3. if the handler interrupts a blocking system call, then that system call is automatically restarted πŸ”

meanwhile a portable application literally cannot rely on signal(2) to give you any of those guarantees. so like… note that, bestie πŸ“


πŸ’« RETURN VALUE πŸ’«

bsd_signal() hands you back the previous value of the signal handler, or SIG_ERR if something went wrong. SIG_ERR is giving πŸ’€, the previous value is giving πŸ‘‘


🚨 ERRORS 🚨

same as signal(2), fr fr. go read that one.


πŸ‘‘ ATTRIBUTES πŸ‘‘

for an explanation of the terms used in this section, see attributes(7). since we can't do tables here (the vibes forbid it), here's the tea in list form:

  • bsd_signal() β€” Thread safety: MT-Safe 🧡✨ (yes bestie, it's thread-safe, we love to see it)

πŸ’… VERSIONS πŸ’…

okay real talk:

Use of bsd_signal() should be avoided; use sigaction(2) instead.

not me being dramatic, that's literally what it says. use sigaction(2). periodt.

on modern Linux systems, bsd_signal() and signal(2) are equivalent. but on older systems, signal(2) provided unreliable signal semantics β€” check signal(2) for the details if you're curious πŸ‘€

and psa: the use of sighandler_t is a GNU extension πŸ‚ β€” this type is defined only if the _GNU_SOURCE feature test macro is defined. so if it's not showing up, that's why, and now you know πŸŽ€


πŸ“œ STANDARDS πŸ“œ

None. that's it. that's the whole section. iconic behaviour honestly πŸ’€


πŸ¦‹ HISTORY πŸ¦‹

  • 4.2BSD, POSIX.1-2001.
  • Removed in POSIX.1-2008, recommending the use of sigaction(2) instead. so it got un-invited from the party πŸ₯²

🌟 SEE ALSO 🌟


k that's the whole page bestie, go handle your signals responsibly 🫢✨

this was Linux man-pages 6.20, dated 2026-02-08 β€” mwah, love that for us πŸ’œ

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