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