diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2001-01-18 18:51:45 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2001-01-18 18:51:45 +0000 |
commit | ba6d491b7f303f0be747395034088afc6fde7a64 (patch) | |
tree | 10a13243cd355d38a1a9bbba5d0230dfa398e9ab /lib/libc/compat-43/sigsetmask.3 | |
parent | 8dc6f7494792459cb3f382bfdf78a16fc74acc7d (diff) |
Provide examples showing how to convert old code to use sigprocmask(2).
Diffstat (limited to 'lib/libc/compat-43/sigsetmask.3')
-rw-r--r-- | lib/libc/compat-43/sigsetmask.3 | 61 |
1 files changed, 60 insertions, 1 deletions
diff --git a/lib/libc/compat-43/sigsetmask.3 b/lib/libc/compat-43/sigsetmask.3 index 79f7e9b75f0..613ef08670a 100644 --- a/lib/libc/compat-43/sigsetmask.3 +++ b/lib/libc/compat-43/sigsetmask.3 @@ -29,7 +29,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $OpenBSD: sigsetmask.3,v 1.9 2000/01/06 07:29:08 d Exp $ +.\" $OpenBSD: sigsetmask.3,v 1.10 2001/01/18 18:51:44 millert Exp $ .\" .Dd March 10, 1991 .Dt SIGSETMASK 3 @@ -64,6 +64,65 @@ quietly disallows or .Dv SIGSTOP to be blocked. +.Sh EXAMPLES +The following example utilizing +.Fn sigsetmask : +.Bd -literal -offset indent +int omask; + +omask = sigblock(sigmask(SIGINT) | sigmask(SIGHUP)); + +\&... + +sigsetmask(omask & ~(sigmask(SIGINT) | sigmask(SIGHUP))); +.Ed +.Pp +Could be converted literally to: +.Bd -literal -offset indent +sigset_t set, oset; + +sigemptyset(&set); +sigaddset(&set, SIGINT); +sigaddset(&set, SIGHUP); +sigprocmask(SIG_BLOCK, &set, &oset); + +\&... + +sigdelset(&oset, SIGINT); +sigdelset(&oset, SIGHUP); +sigprocmask(SIG_SETMASK, &oset, NULL); +.Ed +.Pp +Another, clearer, alternative is: +.Bd -literal -offset indent +sigset_t set; + +sigemptyset(&set); +sigaddset(&set, SIGINT); +sigaddset(&set, SIGHUP); +sigprocmask(SIG_BLOCK, &set, NULL); + +\&... + +sigprocmask(SIG_UNBLOCK, &set, NULL); +.Ed +.Pp +To completely clear the signal mask using +.Fn sigsetmask +one can do: +.Bd -literal -offset indent +(void) sigsetmask(0); +.Ed +.Pp +Which can be expressed via +.Xr sigprocmask 2 +as: +.Bd -literal -offset indent +sigset_t eset; + +sigemptyset(&eset); +(void) sigprocmask(SIG_SETMASK, &eset, NULL); +.Ed .Sh RETURN VALUES The previous set of masked signals is returned. .Sh SEE ALSO |