Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc/compat-43 bring in EXAMPLES sections from openbsd.



details:   https://anonhg.NetBSD.org/src/rev/e7182cabec7b
branches:  trunk
changeset: 535091:e7182cabec7b
user:      yamt <yamt%NetBSD.org@localhost>
date:      Sat Aug 10 02:41:21 2002 +0000

description:
bring in EXAMPLES sections from openbsd.

diffstat:

 lib/libc/compat-43/sigblock.3   |  38 ++++++++++++++++++++++++-
 lib/libc/compat-43/sigsetmask.3 |  61 ++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 97 insertions(+), 2 deletions(-)

diffs (133 lines):

diff -r c9c6913cf783 -r e7182cabec7b lib/libc/compat-43/sigblock.3
--- a/lib/libc/compat-43/sigblock.3     Sat Aug 10 02:03:21 2002 +0000
+++ b/lib/libc/compat-43/sigblock.3     Sat Aug 10 02:41:21 2002 +0000
@@ -30,7 +30,7 @@
 .\" SUCH DAMAGE.
 .\"
 .\"     from: @(#)sigblock.2   8.1 (Berkeley) 6/2/93
-.\"    $NetBSD: sigblock.3,v 1.12 2002/02/07 07:00:09 ross Exp $
+.\"    $NetBSD: sigblock.3,v 1.13 2002/08/10 02:41:21 yamt Exp $
 .\"
 .Dd June 2, 1993
 .Dt SIGBLOCK 3
@@ -71,6 +71,42 @@
 .Dv SIGSTOP ;
 this restriction is silently
 imposed by the system.
+.Sh EXAMPLES
+The following example utilizing
+.Fn sigblock :
+.Bd -literal -offset indent
+int omask;
+
+omask = sigblock(sigmask(SIGINT) | sigmask(SIGHUP));
+.Ed
+.Pp
+Becomes:
+.Bd -literal -offset indent
+sigset_t set, oset;
+
+sigemptyset(&set);
+sigaddset(&set, SIGINT);
+sigaddset(&set, SIGHUP);
+sigprocmask(SIG_BLOCK, &set, &oset);
+.Ed
+.Pp
+Another use of
+.Fn sigblock
+is to get the current set of masked signals without changing what
+is actually blocked.
+Instead of:
+.Bd -literal -offset indent
+int set;
+
+set = sigblock(0);
+.Ed
+.Pp
+Use the following:
+.Bd -literal -offset indent
+sigset_t set;
+
+sigprocmask(SIG_BLOCK, NULL, &set);
+.Ed
 .Sh RETURN VALUES
 The previous set of masked signals is returned.
 .Sh SEE ALSO
diff -r c9c6913cf783 -r e7182cabec7b lib/libc/compat-43/sigsetmask.3
--- a/lib/libc/compat-43/sigsetmask.3   Sat Aug 10 02:03:21 2002 +0000
+++ b/lib/libc/compat-43/sigsetmask.3   Sat Aug 10 02:41:21 2002 +0000
@@ -30,7 +30,7 @@
 .\" SUCH DAMAGE.
 .\"
 .\"     from: @(#)sigsetmask.2 8.1 (Berkeley) 6/2/93
-.\"    $NetBSD: sigsetmask.3,v 1.13 2002/02/07 07:00:09 ross Exp $
+.\"    $NetBSD: sigsetmask.3,v 1.14 2002/08/10 02:41:21 yamt Exp $
 .\"
 .Dd June 2, 1993
 .Dt SIGSETMASK 3
@@ -67,6 +67,65 @@
 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



Home | Main Index | Thread Index | Old Index