Changes.old: Add missing entry in 5.13 changelog
[man-pages.git] / man3 / bsd_signal.3
blobf944255021cb65080bbfb058bcb9c1045e17ac16
1 .\" Copyright (c) 2007 Michael Kerrisk <mtk.manpages@gmail.com>
2 .\"
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
7 .\"
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
12 .\"
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein.  The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" %%%LICENSE_END
24 .\"
25 .TH BSD_SIGNAL 3 2021-03-22 "" "Linux Programmer's Manual"
26 .SH NAME
27 bsd_signal \- signal handling with BSD semantics
28 .SH SYNOPSIS
29 .nf
30 .B #include <signal.h>
31 .PP
32 .B typedef void (*sighandler_t)(int);
33 .PP
34 .BI "sighandler_t bsd_signal(int " signum ", sighandler_t " handler );
35 .fi
36 .PP
37 .RS -4
38 Feature Test Macro Requirements for glibc (see
39 .BR feature_test_macros (7)):
40 .RE
41 .PP
42 .BR bsd_signal ():
43 .nf
44     Since glibc 2.26:
45         _XOPEN_SOURCE >= 500
46 .\"    || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED
47             && ! (_POSIX_C_SOURCE >= 200809L)
48     Glibc 2.25 and earlier:
49         _XOPEN_SOURCE
50 .fi
51 .SH DESCRIPTION
52 The
53 .BR bsd_signal ()
54 function takes the same arguments, and performs the same task, as
55 .BR signal (2).
56 .PP
57 The difference between the two is that
58 .BR bsd_signal ()
59 is guaranteed to provide reliable signal semantics, that is:
60 a) the disposition of the signal is not reset to the default
61 when the handler is invoked;
62 b) delivery of further instances of the signal is blocked while
63 the signal handler is executing; and
64 c) if the handler interrupts a blocking system call,
65 then the system call is automatically restarted.
66 A portable application cannot rely on
67 .BR signal (2)
68 to provide these guarantees.
69 .SH RETURN VALUE
70 The
71 .BR bsd_signal ()
72 function returns the previous value of the signal handler, or
73 .B SIG_ERR
74 on error.
75 .SH ERRORS
76 As for
77 .BR signal (2).
78 .SH ATTRIBUTES
79 For an explanation of the terms used in this section, see
80 .BR attributes (7).
81 .ad l
82 .nh
83 .TS
84 allbox;
85 lbx lb lb
86 l l l.
87 Interface       Attribute       Value
89 .BR bsd_signal ()
90 T}      Thread safety   MT-Safe
91 .TE
92 .hy
93 .ad
94 .sp 1
95 .SH CONFORMING TO
96 4.2BSD, POSIX.1-2001.
97 POSIX.1-2008 removes the specification of
98 .BR bsd_signal (),
99 recommending the use of
100 .BR sigaction (2)
101 instead.
102 .SH NOTES
103 Use of
104 .BR bsd_signal ()
105 should be avoided; use
106 .BR sigaction (2)
107 instead.
109 On modern Linux systems,
110 .BR bsd_signal ()
112 .BR signal (2)
113 are equivalent.
114 But on older systems,
115 .BR signal (2)
116 provided unreliable signal semantics; see
117 .BR signal (2)
118 for details.
120 The use of
121 .I sighandler_t
122 is a GNU extension;
123 this type is defined only if the
124 .B _GNU_SOURCE
125 feature test macro is defined.
126 .SH SEE ALSO
127 .BR sigaction (2),
128 .BR signal (2),
129 .BR sysv_signal (3),
130 .BR signal (7)