]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/bsd_signal.3
bsd_signal.3: ATTRIBUTES: Note function that is thread-safe
[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.\"
1d4be868 25.TH BSD_SIGNAL 3 2013-10-22 "" "Linux Programmer's Manual"
2e8d048a
MK
26.SH NAME
27bsd_signal \- signal handling with BSD semantics
28.SH SYNOPSIS
b80f966b 29.BR "#define _XOPEN_SOURCE" " /* See feature_test_macros(7) */"
2e8d048a
MK
30.br
31.B #include <signal.h>
32.sp
33.B typedef void (*sighandler_t)(int);
34.sp
35.BI "sighandler_t bsd_signal(int " signum ", sighandler_t " handler );
36.SH DESCRIPTION
37The
38.BR bsd_signal ()
39function takes the same arguments, and performs the same task, as
40.BR signal (2).
41
42The difference between the two is that
43.BR bsd_signal ()
44is guaranteed to provide reliable signal semantics, that is:
45a) the disposition of the signal is not reset to the default
46when the handler is invoked;
47b) delivery of further instances of the signal is blocked while
48the signal handler is executing; and
49c) if the handler interrupts a blocking system call,
50then the system call is automatically restarted.
51A portable application cannot rely on
52.BR signal (2)
53to provide these guarantees.
47297adb 54.SH RETURN VALUE
2e8d048a
MK
55The
56.BR bsd_signal ()
57function returns the previous value of the signal handler, or
58.B SIG_ERR
59on error.
60.SH ERRORS
61As for
62.BR signal (2).
1d4be868
PH
63.SH ATTRIBUTES
64.SS Multithreading (see pthreads(7))
65The
66.BR bsd_signal ()
67function is thread-safe.
47297adb 68.SH CONFORMING TO
2b2581ee 694.2BSD, POSIX.1-2001.
44a31ea5 70POSIX.1-2008 removes the specification of
67bb8742
MK
71.BR bsd_signal (),
72recommending the use of
73.BR sigaction (2)
74instead.
2e8d048a
MK
75.SH NOTES
76Use of
77.BR bsd_signal ()
78should be avoided; use
79.BR sigaction (2)
80instead.
81
82On modern Linux systems,
83.BR bsd_signal ()
84and
85.BR signal (2)
86are equivalent.
988db661 87But on older systems,
2e8d048a
MK
88.BR signal (2)
89provided unreliable signal semantics; see
90.BR signal (2)
91for details.
92
93The use of
66ee0c7e 94.I sighandler_t
2e8d048a 95is a GNU extension;
33a0ccb2 96this type is defined only if the
c3dfd2c8
MK
97.B _GNU_SOURCE
98feature test macro is defined.
47297adb 99.SH SEE ALSO
2e8d048a
MK
100.BR sigaction (2),
101.BR signal (2),
102.BR sysv_signal (3),
2e8d048a 103.BR signal (7)