]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3/bsd_signal.3
CPU_SET.3, INFINITY.3, __ppc_get_timebase.3, __ppc_set_ppr_med.3, __ppc_yield.3,...
[thirdparty/man-pages.git] / man3 / bsd_signal.3
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 2017-07-13 "" "Linux Programmer's Manual"
26 .SH NAME
27 bsd_signal \- signal handling with BSD semantics
28 .SH SYNOPSIS
29 .B #include <signal.h>
30 .PP
31 .B typedef void (*sighandler_t)(int);
32 .PP
33 .BI "sighandler_t bsd_signal(int " signum ", sighandler_t " handler );
34 .PP
35 .in -4n
36 Feature Test Macro Requirements for glibc (see
37 .BR feature_test_macros (7)):
38 .in
39 .PP
40 .ad l
41 .BR bsd_signal ():
42 .RS 4
43 Since glibc 2.26:
44 _XOPEN_SOURCE >= 500
45 .\" || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED
46 && ! (_POSIX_C_SOURCE\ >=\ 200112L)
47 .br
48 Glibc 2.25 and earlier:
49 _XOPEN_SOURCE
50 .RE
51 .ad b
52 .SH DESCRIPTION
53 The
54 .BR bsd_signal ()
55 function takes the same arguments, and performs the same task, as
56 .BR signal (2).
57 .PP
58 The difference between the two is that
59 .BR bsd_signal ()
60 is guaranteed to provide reliable signal semantics, that is:
61 a) the disposition of the signal is not reset to the default
62 when the handler is invoked;
63 b) delivery of further instances of the signal is blocked while
64 the signal handler is executing; and
65 c) if the handler interrupts a blocking system call,
66 then the system call is automatically restarted.
67 A portable application cannot rely on
68 .BR signal (2)
69 to provide these guarantees.
70 .SH RETURN VALUE
71 The
72 .BR bsd_signal ()
73 function returns the previous value of the signal handler, or
74 .B SIG_ERR
75 on error.
76 .SH ERRORS
77 As for
78 .BR signal (2).
79 .SH ATTRIBUTES
80 For an explanation of the terms used in this section, see
81 .BR attributes (7).
82 .TS
83 allbox;
84 lb lb lb
85 l l l.
86 Interface Attribute Value
87 T{
88 .BR bsd_signal ()
89 T} Thread safety MT-Safe
90 .TE
91 .SH CONFORMING TO
92 4.2BSD, POSIX.1-2001.
93 POSIX.1-2008 removes the specification of
94 .BR bsd_signal (),
95 recommending the use of
96 .BR sigaction (2)
97 instead.
98 .SH NOTES
99 Use of
100 .BR bsd_signal ()
101 should be avoided; use
102 .BR sigaction (2)
103 instead.
104 .PP
105 On modern Linux systems,
106 .BR bsd_signal ()
107 and
108 .BR signal (2)
109 are equivalent.
110 But on older systems,
111 .BR signal (2)
112 provided unreliable signal semantics; see
113 .BR signal (2)
114 for details.
115 .PP
116 The use of
117 .I sighandler_t
118 is a GNU extension;
119 this type is defined only if the
120 .B _GNU_SOURCE
121 feature test macro is defined.
122 .SH SEE ALSO
123 .BR sigaction (2),
124 .BR signal (2),
125 .BR sysv_signal (3),
126 .BR signal (7)