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