xref: /openbsd/lib/libc/compat-43/sigblock.3 (revision 73471bf0)
1.\" Copyright (c) 1983, 1991 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\" 3. Neither the name of the University nor the names of its contributors
13.\"    may be used to endorse or promote products derived from this software
14.\"    without specific prior written permission.
15.\"
16.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26.\" SUCH DAMAGE.
27.\"
28.\"	$OpenBSD: sigblock.3,v 1.20 2017/08/01 15:38:02 schwarze Exp $
29.\"
30.Dd $Mdocdate: August 1 2017 $
31.Dt SIGBLOCK 3
32.Os
33.Sh NAME
34.Nm sigblock ,
35.Nm sigmask
36.Nd block signals
37.Sh SYNOPSIS
38.In signal.h
39.Ft int
40.Fn sigblock "int mask"
41.Ft int
42.Fn sigmask "int signum"
43.Sh DESCRIPTION
44.Bf -symbolic
45This interface is made obsolete by
46.Ef
47.Xr sigprocmask 2 .
48.Pp
49.Fn sigblock
50adds the signals specified in
51.Fa mask
52to the set of signals currently
53being blocked from delivery.
54Signals are blocked if the
55corresponding bit in
56.Fa mask
57is a 1; the macro
58.Fn sigmask
59is provided to construct the mask for a given
60.Fa signum .
61.Pp
62It is not possible to block
63.Dv SIGKILL
64or
65.Dv SIGSTOP ;
66this restriction is silently
67imposed by the system.
68.Sh RETURN VALUES
69The previous set of masked signals is returned.
70.Sh EXAMPLES
71The following example utilizing
72.Fn sigblock :
73.Bd -literal -offset indent
74int omask;
75
76omask = sigblock(sigmask(SIGINT) | sigmask(SIGHUP));
77.Ed
78.Pp
79Becomes:
80.Bd -literal -offset indent
81sigset_t set, oset;
82
83sigemptyset(&set);
84sigaddset(&set, SIGINT);
85sigaddset(&set, SIGHUP);
86sigprocmask(SIG_BLOCK, &set, &oset);
87.Ed
88.Pp
89Another use of
90.Fn sigblock
91is to get the current set of masked signals without changing what
92is actually blocked.
93Instead of:
94.Bd -literal -offset indent
95int set;
96
97set = sigblock(0);
98.Ed
99.Pp
100Use the following:
101.Bd -literal -offset indent
102sigset_t set;
103
104sigprocmask(SIG_BLOCK, NULL, &set);
105.Ed
106.Sh SEE ALSO
107.Xr kill 2 ,
108.Xr sigaction 2 ,
109.Xr sigprocmask 2 ,
110.Xr sigaddset 3 ,
111.Xr sigsetmask 3
112.Sh HISTORY
113A
114.Fn sigblock
115system call first appeared in
116.Bx 4.2 .
117In
118.Bx 4.3 Reno ,
119it was reimplemented as a wrapper around
120.Xr sigprocmask 2 .
121The old system call was kept for compatibility until
122.Ox 4.9 .
123