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:
- the disposition of the signal is not reset to the default when the handler gets invoked π
- delivery of further instances of the signal is blocked while the signal handler is executing π
- 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 ofbsd_signal()should be avoided; usesigaction(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 ofsigaction(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
- Copyright 2007, Michael Kerrisk <mtk.manpages@gmail.com>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms