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