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