xref: /openbsd-src/lib/libc/compat-43/sigblock.3 (revision 2b0358df1d88d06ef4139321dd05bd5e05d91eaf)
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.14 2007/05/31 19:19:27 jmc Exp $
29.\"
30.Dd $Mdocdate: May 31 2007 $
31.Dt SIGBLOCK 3
32.Os
33.Sh NAME
34.Nm sigblock
35.Nd block signals
36.Sh SYNOPSIS
37.Fd #include <signal.h>
38.Ft int
39.Fn sigblock "int mask"
40.Ft int
41.Fn sigmask "int signum"
42.Sh DESCRIPTION
43.Bf -symbolic
44This interface is made obsolete by:
45.Ef
46.Xr sigprocmask 2 .
47.Pp
48.Fn sigblock
49adds the signals specified in
50.Fa mask
51to the set of signals currently
52being blocked from delivery.
53Signals are blocked if the
54corresponding bit in
55.Fa mask
56is a 1; the macro
57.Fn sigmask
58is provided to construct the mask for a given
59.Fa signum .
60.Pp
61It is not possible to block
62.Dv SIGKILL
63or
64.Dv SIGSTOP ;
65this restriction is silently
66imposed by the system.
67.Sh RETURN VALUES
68The previous set of masked signals is returned.
69.Sh EXAMPLES
70The following example utilizing
71.Fn sigblock :
72.Bd -literal -offset indent
73int omask;
74
75omask = sigblock(sigmask(SIGINT) | sigmask(SIGHUP));
76.Ed
77.Pp
78Becomes:
79.Bd -literal -offset indent
80sigset_t set, oset;
81
82sigemptyset(&set);
83sigaddset(&set, SIGINT);
84sigaddset(&set, SIGHUP);
85sigprocmask(SIG_BLOCK, &set, &oset);
86.Ed
87.Pp
88Another use of
89.Fn sigblock
90is to get the current set of masked signals without changing what
91is actually blocked.
92Instead of:
93.Bd -literal -offset indent
94int set;
95
96set = sigblock(0);
97.Ed
98.Pp
99Use the following:
100.Bd -literal -offset indent
101sigset_t set;
102
103sigprocmask(SIG_BLOCK, NULL, &set);
104.Ed
105.Sh SEE ALSO
106.Xr kill 2 ,
107.Xr sigaction 2 ,
108.Xr sigprocmask 2 ,
109.Xr sigsetmask 3 ,
110.Xr sigsetops 3
111.Sh HISTORY
112The
113.Fn sigblock
114function call appeared in
115.Bx 4.2
116and has been deprecated.
117