OSDN Git Service

initial commit
[openbsd-octeon/openbsd-octeon.git] / src / lib / libc / compat-43 / sigsetmask.3
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: sigsetmask.3,v 1.13 2007/05/31 19:19:27 jmc Exp $
29 .\"
30 .Dd $Mdocdate: May 31 2007 $
31 .Dt SIGSETMASK 3
32 .Os
33 .Sh NAME
34 .Nm sigsetmask
35 .Nd set current signal mask
36 .Sh SYNOPSIS
37 .Fd #include <signal.h>
38 .Ft int
39 .Fn sigsetmask "int mask"
40 .Fn sigmask "int signum"
41 .Sh DESCRIPTION
42 .Bf -symbolic
43 This interface is made obsoleted by:
44 .Ef
45 .Xr sigprocmask 2 .
46 .Pp
47 .Fn sigsetmask
48 sets the current signal mask.
49 Signals are blocked from delivery if the
50 corresponding bit in
51 .Fa mask
52 is a 1; the macro
53 .Fn sigmask
54 is provided to construct the mask for a given
55 .Fa signum .
56 .Pp
57 The system
58 quietly disallows
59 .Dv SIGKILL
60 or
61 .Dv SIGSTOP
62 to be blocked.
63 .Sh RETURN VALUES
64 The previous set of masked signals is returned.
65 .Sh EXAMPLES
66 The following example utilizing
67 .Fn sigsetmask :
68 .Bd -literal -offset indent
69 int omask;
70
71 omask = sigblock(sigmask(SIGINT) | sigmask(SIGHUP));
72
73 \&...
74
75 sigsetmask(omask & ~(sigmask(SIGINT) | sigmask(SIGHUP)));
76 .Ed
77 .Pp
78 Could be converted literally to:
79 .Bd -literal -offset indent
80 sigset_t set, oset;
81
82 sigemptyset(&set);
83 sigaddset(&set, SIGINT);
84 sigaddset(&set, SIGHUP);
85 sigprocmask(SIG_BLOCK, &set, &oset);
86
87 \&...
88
89 sigdelset(&oset, SIGINT);
90 sigdelset(&oset, SIGHUP);
91 sigprocmask(SIG_SETMASK, &oset, NULL);
92 .Ed
93 .Pp
94 Another, clearer, alternative is:
95 .Bd -literal -offset indent
96 sigset_t set;
97
98 sigemptyset(&set);
99 sigaddset(&set, SIGINT);
100 sigaddset(&set, SIGHUP);
101 sigprocmask(SIG_BLOCK, &set, NULL);
102
103 \&...
104
105 sigprocmask(SIG_UNBLOCK, &set, NULL);
106 .Ed
107 .Pp
108 To completely clear the signal mask using
109 .Fn sigsetmask
110 one can do:
111 .Bd -literal -offset indent
112 (void) sigsetmask(0);
113 .Ed
114 .Pp
115 Which can be expressed via
116 .Xr sigprocmask 2
117 as:
118 .Bd -literal -offset indent
119 sigset_t eset;
120
121 sigemptyset(&eset);
122 (void) sigprocmask(SIG_SETMASK, &eset, NULL);
123 .Ed
124 .Sh SEE ALSO
125 .Xr kill 2 ,
126 .Xr sigaction 2 ,
127 .Xr sigprocmask 2 ,
128 .Xr sigsuspend 2 ,
129 .Xr sigblock 3 ,
130 .Xr sigsetops 3 ,
131 .Xr sigvec 3
132 .Sh HISTORY
133 The
134 .Fn sigsetmask
135 function call appeared in
136 .Bx 4.2
137 and has been deprecated.