summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2001-09-04 23:36:00 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2001-09-04 23:36:00 +0000
commit6e69b2a3e9a34411460d33a432a805b3eb1924d1 (patch)
tree33cfe52f5da9645a00ca15af49ceefdd612696d2 /lib
parent102264589c8731b5f0fb00b204e5963726ecec83 (diff)
Replace the deprecated BSD sigsetmask/sigblock/sigpause functions with their POSIX counterparts.
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/gen/pause.c42
-rw-r--r--lib/libc/net/rcmd.c16
-rw-r--r--lib/libc/stdlib/system.c14
3 files changed, 25 insertions, 47 deletions
diff --git a/lib/libc/gen/pause.c b/lib/libc/gen/pause.c
index 489817d887b..c7fc83c0a67 100644
--- a/lib/libc/gen/pause.c
+++ b/lib/libc/gen/pause.c
@@ -1,49 +1,23 @@
+/* $OpenBSD: pause.c,v 1.3 2001/09/04 23:35:58 millert Exp $ */
+
/*
- * Copyright (c) 1983, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
+ * Written by Todd C. Miller <Todd.Miller@courtesan.com>
+ * Public domain.
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: pause.c,v 1.2 1996/08/19 08:25:16 tholo Exp $";
+static const char rcsid[] = "$OpenBSD: pause.c,v 1.3 2001/09/04 23:35:58 millert Exp $";
#endif /* LIBC_SCCS and not lint */
#include <signal.h>
-#include <unistd.h>
/*
- * Backwards compatible pause.
+ * Backwards compatible pause(3).
*/
int
pause()
{
+ sigset_t mask;
- return sigpause(sigblock(0L));
+ return (sigprocmask(SIG_BLOCK, NULL, &mask) ? -1 : sigsuspend(&mask));
}
diff --git a/lib/libc/net/rcmd.c b/lib/libc/net/rcmd.c
index 1439fff061a..a9fdc1b1d04 100644
--- a/lib/libc/net/rcmd.c
+++ b/lib/libc/net/rcmd.c
@@ -34,7 +34,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char *rcsid = "$OpenBSD: rcmd.c,v 1.38 2001/06/27 00:58:55 lebel Exp $";
+static char *rcsid = "$OpenBSD: rcmd.c,v 1.39 2001/09/04 23:35:58 millert Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
@@ -87,7 +87,7 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af)
int error;
struct sockaddr_storage from;
fd_set *readsp = NULL;
- int oldmask;
+ sigset_t oldmask, mask;
pid_t pid;
int s, lport, timo;
char c, *p;
@@ -132,7 +132,9 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af)
r = res;
refused = 0;
- oldmask = sigblock(sigmask(SIGURG));
+ sigemptyset(&mask);
+ sigaddset(&mask, SIGURG);
+ oldmask = sigprocmask(SIG_BLOCK, &mask, &oldmask);
for (timo = 1, lport = IPPORT_RESERVED - 1;;) {
s = rresvport_af(&lport, r->ai_family);
if (s < 0) {
@@ -146,7 +148,7 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af)
r = r->ai_next;
continue;
} else {
- sigsetmask(oldmask);
+ sigprocmask(SIG_SETMASK, &oldmask, NULL);
freeaddrinfo(res);
return (-1);
}
@@ -194,7 +196,7 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af)
}
(void)fprintf(stderr, "%s: %s\n", res->ai_canonname,
strerror(errno));
- sigsetmask(oldmask);
+ sigprocmask(SIG_SETMASK, &oldmask, NULL);
freeaddrinfo(res);
return (-1);
}
@@ -306,7 +308,7 @@ again:
}
goto bad2;
}
- sigsetmask(oldmask);
+ sigprocmask(SIG_SETMASK, &oldmask, NULL);
free(readsp);
return (s);
bad2:
@@ -316,7 +318,7 @@ bad:
if (readsp)
free(readsp);
(void)close(s);
- sigsetmask(oldmask);
+ sigprocmask(SIG_SETMASK, &oldmask, NULL);
return (-1);
}
diff --git a/lib/libc/stdlib/system.c b/lib/libc/stdlib/system.c
index 3e1b047393f..dadf3fe8419 100644
--- a/lib/libc/stdlib/system.c
+++ b/lib/libc/stdlib/system.c
@@ -32,7 +32,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char *rcsid = "$OpenBSD: system.c,v 1.3 1996/09/15 09:31:52 tholo Exp $";
+static char *rcsid = "$OpenBSD: system.c,v 1.4 2001/09/04 23:35:58 millert Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
@@ -50,7 +50,7 @@ system(command)
{
pid_t pid;
sig_t intsave, quitsave;
- int omask;
+ sigset_t mask, omask;
int pstat;
char *argp[] = {"sh", "-c", NULL, NULL};
@@ -59,13 +59,15 @@ system(command)
argp[2] = (char *)command;
- omask = sigblock(sigmask(SIGCHLD));
+ sigemptyset(&mask);
+ sigaddset(&mask, SIGCHLD);
+ sigprocmask(SIG_BLOCK, &mask, &omask);
switch(pid = vfork()) {
case -1: /* error */
- (void)sigsetmask(omask);
+ sigprocmask(SIG_SETMASK, &omask, NULL);
return(-1);
case 0: /* child */
- (void)sigsetmask(omask);
+ sigprocmask(SIG_SETMASK, &omask, NULL);
execve(_PATH_BSHELL, argp, environ);
_exit(127);
}
@@ -73,7 +75,7 @@ system(command)
intsave = signal(SIGINT, SIG_IGN);
quitsave = signal(SIGQUIT, SIG_IGN);
pid = waitpid(pid, (int *)&pstat, 0);
- (void)sigsetmask(omask);
+ sigprocmask(SIG_SETMASK, &omask, NULL);
(void)signal(SIGINT, intsave);
(void)signal(SIGQUIT, quitsave);
return(pid == -1 ? -1 : pstat);