| 1 |
'\" t |
| 2 |
.\" Copyright 2007, Michael Kerrisk <[email protected]> |
| 3 |
.\" Copyright, the authors of the Linux man-pages project |
| 4 |
.\" |
| 5 |
.\" SPDX-License-Identifier: Linux-man-pages-copyleft |
| 6 |
.\" |
| 7 |
.TH bsd_signal 3 2026-02-08 "Linux man-pages 6.18" |
| 8 |
.SH NAME |
| 9 |
bsd_signal \- signal handling with BSD semantics |
| 10 |
.SH LIBRARY |
| 11 |
Standard C library |
| 12 |
.RI ( libc ,\~ \-lc ) |
| 13 |
.SH SYNOPSIS |
| 14 |
.nf |
| 15 |
.B #include <signal.h> |
| 16 |
.P |
| 17 |
.B "typedef typeof(void (int)) *sighandler_t;" |
| 18 |
.P |
| 19 |
.BI "sighandler_t bsd_signal(int " signum ", sighandler_t " handler ); |
| 20 |
.fi |
| 21 |
.P |
| 22 |
.RS -4 |
| 23 |
Feature Test Macro Requirements for glibc (see |
| 24 |
.BR feature_test_macros (7)): |
| 25 |
.RE |
| 26 |
.P |
| 27 |
.BR bsd_signal (): |
| 28 |
.nf |
| 29 |
Since glibc 2.26: |
| 30 |
_XOPEN_SOURCE >= 500 |
| 31 |
.\" || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED |
| 32 |
&& ! (_POSIX_C_SOURCE >= 200809L) |
| 33 |
glibc 2.25 and earlier: |
| 34 |
_XOPEN_SOURCE |
| 35 |
.fi |
| 36 |
.SH DESCRIPTION |
| 37 |
The |
| 38 |
.BR bsd_signal () |
| 39 |
function takes the same arguments, and performs the same task, as |
| 40 |
.BR signal (2). |
| 41 |
.P |
| 42 |
The difference between the two is that |
| 43 |
.BR bsd_signal () |
| 44 |
is guaranteed to provide reliable signal semantics, that is: |
| 45 |
a) the disposition of the signal is not reset to the default |
| 46 |
when the handler is invoked; |
| 47 |
b) delivery of further instances of the signal is blocked |
| 48 |
while the signal handler is executing; |
| 49 |
and |
| 50 |
c) if the handler interrupts a blocking system call, |
| 51 |
then the system call is automatically restarted. |
| 52 |
A portable application cannot rely on |
| 53 |
.BR signal (2) |
| 54 |
to provide these guarantees. |
| 55 |
.SH RETURN VALUE |
| 56 |
The |
| 57 |
.BR bsd_signal () |
| 58 |
function returns the previous value of the signal handler, or |
| 59 |
.B SIG_ERR |
| 60 |
on error. |
| 61 |
.SH ERRORS |
| 62 |
As for |
| 63 |
.BR signal (2). |
| 64 |
.SH ATTRIBUTES |
| 65 |
For an explanation of the terms used in this section, see |
| 66 |
.BR attributes (7). |
| 67 |
.TS |
| 68 |
allbox; |
| 69 |
lbx lb lb |
| 70 |
l l l. |
| 71 |
Interface Attribute Value |
| 72 |
T{ |
| 73 |
.na |
| 74 |
.nh |
| 75 |
.BR bsd_signal () |
| 76 |
T} Thread safety MT-Safe |
| 77 |
.TE |
| 78 |
.SH VERSIONS |
| 79 |
Use of |
| 80 |
.BR bsd_signal () |
| 81 |
should be avoided; |
| 82 |
use |
| 83 |
.BR sigaction (2) |
| 84 |
instead. |
| 85 |
.P |
| 86 |
On modern Linux systems, |
| 87 |
.BR bsd_signal () |
| 88 |
and |
| 89 |
.BR signal (2) |
| 90 |
are equivalent. |
| 91 |
But on older systems, |
| 92 |
.BR signal (2) |
| 93 |
provided unreliable signal semantics; |
| 94 |
see |
| 95 |
.BR signal (2) |
| 96 |
for details. |
| 97 |
.P |
| 98 |
The use of |
| 99 |
.I sighandler_t |
| 100 |
is a GNU extension; |
| 101 |
this type is defined only if the |
| 102 |
.B _GNU_SOURCE |
| 103 |
feature test macro is defined. |
| 104 |
.SH STANDARDS |
| 105 |
None. |
| 106 |
.SH HISTORY |
| 107 |
4.2BSD, POSIX.1-2001. |
| 108 |
Removed in POSIX.1-2008, |
| 109 |
recommending the use of |
| 110 |
.BR sigaction (2) |
| 111 |
instead. |
| 112 |
.SH SEE ALSO |
| 113 |
.BR sigaction (2), |
| 114 |
.BR signal (2), |
| 115 |
.BR sysv_signal (3), |
| 116 |
.BR signal (7) |