diff options
35 files changed, 348 insertions, 439 deletions
diff --git a/games/larn/signal.c b/games/larn/signal.c index 65cf477fab4..cf1cc7ddc59 100644 --- a/games/larn/signal.c +++ b/games/larn/signal.c @@ -1,10 +1,10 @@ -/* $OpenBSD: signal.c,v 1.3 1998/09/15 05:12:33 pjanzen Exp $ */ +/* $OpenBSD: signal.c,v 1.4 2001/09/04 23:35:57 millert Exp $ */ /* $NetBSD: signal.c,v 1.6 1997/10/18 20:03:50 christos Exp $ */ /* "Larn is copyrighted 1986 by Noah Morgan.\n" */ #ifndef lint -static char rcsid[] = "$OpenBSD: signal.c,v 1.3 1998/09/15 05:12:33 pjanzen Exp $"; +static char rcsid[] = "$OpenBSD: signal.c,v 1.4 2001/09/04 23:35:57 millert Exp $"; #endif /* not lint */ #include <stdio.h> @@ -20,8 +20,6 @@ static void sgam __P((int)); static void tstop __P((int)); static void sigpanic __P((int)); -#define BIT(a) (1<<((a)-1)) - static void s2choose() { /* text to be displayed if ^C during intro @@ -69,20 +67,24 @@ sgam(n) static void tstop(n) int n; -{ /* control Y */ +{ /* control Z */ if (nosignal) return; /* nothing if inhibited */ lcreat((char *) 0); clearvt100(); lflush(); signal(SIGTSTP, SIG_DFL); -#ifdef SIGVTALRM - /* - * looks like BSD4.2 or higher - must clr mask for signal to take - * effect - */ - sigsetmask(sigblock(0) & ~BIT(SIGTSTP)); -#endif + if (n == SIGTSTP) { + sigset_t mask; + + /* + * We have to unblock SIGTSTP for the kill() below to + * have any effect. + */ + sigemptyset(&mask); + sigaddset(&mask, SIGTSTP); + sigprocmask(SIG_UNBLOCK, &mask, NULL); + } kill(getpid(), SIGTSTP); setupvt100(); diff --git a/games/tetris/screen.c b/games/tetris/screen.c index fcb0abb47a5..17fd2506e0b 100644 --- a/games/tetris/screen.c +++ b/games/tetris/screen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: screen.c,v 1.5 2001/02/13 11:46:01 pjanzen Exp $ */ +/* $OpenBSD: screen.c,v 1.6 2001/09/04 23:35:58 millert Exp $ */ /* $NetBSD: screen.c,v 1.4 1995/04/29 01:11:36 mycroft Exp $ */ /*- @@ -55,10 +55,6 @@ #include <termios.h> #include <unistd.h> -#ifndef sigmask -#define sigmask(s) (1 << ((s) - 1)) -#endif - #include "screen.h" #include "tetris.h" 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); diff --git a/usr.bin/apply/apply.c b/usr.bin/apply/apply.c index 06875df4a6a..e21a3a05e85 100644 --- a/usr.bin/apply/apply.c +++ b/usr.bin/apply/apply.c @@ -1,4 +1,4 @@ -/* $OpenBSD: apply.c,v 1.9 2001/07/09 07:04:47 deraadt Exp $ */ +/* $OpenBSD: apply.c,v 1.10 2001/09/04 23:35:58 millert Exp $ */ /* $NetBSD: apply.c,v 1.3 1995/03/25 03:38:23 glass Exp $ */ /*- @@ -41,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)apply.c 8.4 (Berkeley) 4/4/94"; #else -static char rcsid[] = "$OpenBSD: apply.c,v 1.9 2001/07/09 07:04:47 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: apply.c,v 1.10 2001/09/04 23:35:58 millert Exp $"; #endif #endif /* not lint */ @@ -198,7 +198,8 @@ system(command) { static char *name, *shell; pid_t pid; - int omask, pstat; + int pstat; + sigset_t mask, omask; sig_t intsave, quitsave; if (shell == NULL) { @@ -212,19 +213,21 @@ system(command) if (!command) /* just checking... */ return(1); - omask = sigblock(sigmask(SIGCHLD)); + sigemptyset(&mask); + sigaddset(&mask, SIGCHLD); + sigprocmask(SIG_BLOCK, &mask, &omask); switch(pid = fork()) { case -1: /* error */ err(1, "fork"); case 0: /* child */ - (void)sigsetmask(omask); + sigprocmask(SIG_SETMASK, &omask, NULL); execl(shell, name, "-c", command, (char *)NULL); err(1, "%s", shell); } intsave = signal(SIGINT, SIG_IGN); quitsave = signal(SIGQUIT, SIG_IGN); pid = waitpid(pid, &pstat, 0); - (void)sigsetmask(omask); + sigprocmask(SIG_SETMASK, &omask, NULL); (void)signal(SIGINT, intsave); (void)signal(SIGQUIT, quitsave); return(pid == -1 ? -1 : pstat); diff --git a/usr.bin/make/job.c b/usr.bin/make/job.c index 2504849b3f2..c1226d4866c 100644 --- a/usr.bin/make/job.c +++ b/usr.bin/make/job.c @@ -1,5 +1,5 @@ /* $OpenPackages$ */ -/* $OpenBSD: job.c,v 1.42 2001/05/29 12:53:40 espie Exp $ */ +/* $OpenBSD: job.c,v 1.43 2001/09/04 23:35:58 millert Exp $ */ /* $NetBSD: job.c,v 1.16 1996/11/06 17:59:08 christos Exp $ */ /* @@ -1236,7 +1236,11 @@ JobExec(job, argv) _exit(1); } else { #ifdef REMOTE - int omask = sigblock(sigmask(SIGCHLD)); + sigset_t mask, omask; + + sigemptyset(&mask); + sigaddset(&mask, SIGCHLD); + sigprocmask(SIG_BLOCK, &mask, &omask); #endif job->pid = cpid; @@ -1284,7 +1288,7 @@ JobExec(job, argv) } } #ifdef REMOTE - (void)sigsetmask(omask); + sigprocmask(SIG_SETMASK, &omask, NULL); #endif } diff --git a/usr.bin/more/more.c b/usr.bin/more/more.c index 7fdc8648ca3..8d00f0fcd9f 100644 --- a/usr.bin/more/more.c +++ b/usr.bin/more/more.c @@ -1,4 +1,4 @@ -/* $OpenBSD: more.c,v 1.12 2001/07/18 17:17:39 pvalchev Exp $ */ +/* $OpenBSD: more.c,v 1.13 2001/09/04 23:35:59 millert Exp $ */ /*- * Copyright (c) 1980 The Regents of the University of California. * All rights reserved. @@ -1853,6 +1853,8 @@ register FILE *f; void onsusp () { + sigset_t mask; + /* ignore SIGTTOU so we don't get stopped if csh grabs the tty */ signal(SIGTTOU, SIG_IGN); reset_tty (); @@ -1860,7 +1862,8 @@ onsusp () signal(SIGTTOU, SIG_DFL); /* Send the TSTP signal to suspend our process group */ signal(SIGTSTP, SIG_DFL); - sigsetmask(0); + sigemptyset(&mask); + sigprocmask(SIG_SETMASK, &mask, NULL); kill (0, SIGTSTP); /* Pause for station break */ diff --git a/usr.bin/msgs/msgs.c b/usr.bin/msgs/msgs.c index 54e2d940f37..bde3fbb9761 100644 --- a/usr.bin/msgs/msgs.c +++ b/usr.bin/msgs/msgs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: msgs.c,v 1.17 2000/08/02 04:10:48 millert Exp $ */ +/* $OpenBSD: msgs.c,v 1.18 2001/09/04 23:35:59 millert Exp $ */ /* $NetBSD: msgs.c,v 1.7 1995/09/28 06:57:40 tls Exp $ */ /*- @@ -44,7 +44,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)msgs.c 8.2 (Berkeley) 4/28/95"; #else -static char rcsid[] = "$OpenBSD: msgs.c,v 1.17 2000/08/02 04:10:48 millert Exp $"; +static char rcsid[] = "$OpenBSD: msgs.c,v 1.18 2001/09/04 23:35:59 millert Exp $"; #endif #endif /* not lint */ @@ -715,8 +715,11 @@ void onsusp(unused) int unused; { + sigset_t emptyset; + signal(SIGTSTP, SIG_DFL); - sigsetmask(0); + sigemptyset(&emptyset); + sigprocmask(SIG_SETMASK, &emptyset, NULL); kill(0, SIGTSTP); signal(SIGTSTP, onsusp); if (!mailing) diff --git a/usr.bin/netstat/if.c b/usr.bin/netstat/if.c index 158849b2934..9eec41f3981 100644 --- a/usr.bin/netstat/if.c +++ b/usr.bin/netstat/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.25 2001/08/26 09:42:04 brian Exp $ */ +/* $OpenBSD: if.c,v 1.26 2001/09/04 23:35:59 millert Exp $ */ /* $NetBSD: if.c,v 1.16.4.2 1996/06/07 21:46:46 thorpej Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "from: @(#)if.c 8.2 (Berkeley) 2/21/94"; #else -static char *rcsid = "$OpenBSD: if.c,v 1.25 2001/08/26 09:42:04 brian Exp $"; +static char *rcsid = "$OpenBSD: if.c,v 1.26 2001/09/04 23:35:59 millert Exp $"; #endif #endif /* not lint */ @@ -376,7 +376,7 @@ struct iftot { int ift_dr; /* drops */ } iftot[MAXIF]; -u_char signalled; /* set if alarm goes off "early" */ +volatile sig_atomic_t signalled; /* set if alarm goes off "early" */ /* * Print a running summary of interface statistics. @@ -395,7 +395,7 @@ sidewaysintpr(interval, off) register int line; struct iftot *lastif, *sum, *interesting; struct ifnet_head ifhead; /* TAILQ_HEAD */ - int oldmask; + sigset_t emptyset; /* * Find the pointer to the first ifnet structure. Replace @@ -552,11 +552,9 @@ loop: putchar('\n'); fflush(stdout); line++; - oldmask = sigblock(sigmask(SIGALRM)); - if (! signalled) { - sigpause(0); - } - sigsetmask(oldmask); + sigemptyset(&emptyset); + if (!signalled) + sigsuspend(&emptyset); signalled = NO; (void)alarm(interval); if (line == 21) diff --git a/usr.bin/nfsstat/nfsstat.c b/usr.bin/nfsstat/nfsstat.c index b8c0fc227f8..2319f370d44 100644 --- a/usr.bin/nfsstat/nfsstat.c +++ b/usr.bin/nfsstat/nfsstat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nfsstat.c,v 1.11 2001/06/25 17:15:46 markus Exp $ */ +/* $OpenBSD: nfsstat.c,v 1.12 2001/09/04 23:35:59 millert Exp $ */ /* $NetBSD: nfsstat.c,v 1.7 1996/03/03 17:21:30 thorpej Exp $ */ /* @@ -48,7 +48,7 @@ static char copyright[] = static char sccsid[] = "from: @(#)nfsstat.c 8.1 (Berkeley) 6/6/93"; static char *rcsid = "$NetBSD: nfsstat.c,v 1.7 1996/03/03 17:21:30 thorpej Exp $"; #else -static char *rcsid = "$OpenBSD: nfsstat.c,v 1.11 2001/06/25 17:15:46 markus Exp $"; +static char *rcsid = "$OpenBSD: nfsstat.c,v 1.12 2001/09/04 23:35:59 millert Exp $"; #endif #endif /* not lint */ @@ -82,7 +82,7 @@ struct nlist nl[] = { { "" }, }; kvm_t *kd; -u_char signalled; /* set if alarm goes off "early" */ +volatile sig_atomic_t signalled; /* set if alarm goes off "early" */ int nfs_id; void getnfsstats __P((struct nfsstats *)); @@ -363,7 +363,8 @@ sidewaysintpr(interval, display) u_int display; { struct nfsstats nfsstats, lastst; - int hdrcnt, oldmask; + int hdrcnt; + sigset_t emptyset; void catchalarm(); (void)signal(SIGALRM, catchalarm); @@ -403,10 +404,9 @@ sidewaysintpr(interval, display) +(nfsstats.srvrpccnt[NFSPROC_READDIRPLUS]-lastst.srvrpccnt[NFSPROC_READDIRPLUS])); lastst = nfsstats; fflush(stdout); - oldmask = sigblock(sigmask(SIGALRM)); + sigemptyset(&emptyset); if (!signalled) - sigpause(0); - sigsetmask(oldmask); + sigsuspend(&emptyset); signalled = 0; (void)alarm(interval); } diff --git a/usr.bin/rlogin/kcmd.c b/usr.bin/rlogin/kcmd.c index aaf7e8b026f..6217c3fd26a 100644 --- a/usr.bin/rlogin/kcmd.c +++ b/usr.bin/rlogin/kcmd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kcmd.c,v 1.12 2001/07/17 02:13:29 pvalchev Exp $ */ +/* $OpenBSD: kcmd.c,v 1.13 2001/09/04 23:35:59 millert Exp $ */ /* $NetBSD: kcmd.c,v 1.2 1995/03/21 07:58:32 cgd Exp $ */ /* @@ -39,7 +39,7 @@ static char Xsccsid[] = "derived from @(#)rcmd.c 5.17 (Berkeley) 6/27/88"; static char sccsid[] = "@(#)kcmd.c 8.2 (Berkeley) 8/19/93"; #else -static char rcsid[] = "$OpenBSD: kcmd.c,v 1.12 2001/07/17 02:13:29 pvalchev Exp $"; +static char rcsid[] = "$OpenBSD: kcmd.c,v 1.13 2001/09/04 23:35:59 millert Exp $"; #endif #endif /* not lint */ @@ -96,7 +96,7 @@ kcmd(sock, ahost, rport, locuser, remuser, cmd, fd2p, ticket, service, realm, long authopts; { int s, timo = 1, pid; - int oldmask; + sigset_t mask, oldmask; struct sockaddr_in sin, from; char c; int lport = IPPORT_RESERVED - 1; @@ -121,7 +121,9 @@ kcmd(sock, ahost, rport, locuser, remuser, cmd, fd2p, ticket, service, realm, if (realm == NULL || realm[0] == '\0') realm = krb_realmofhost(host_save); - oldmask = sigblock(sigmask(SIGURG)); + sigemptyset(&mask); + sigaddset(&mask, SIGURG); + sigprocmask(SIG_BLOCK, &mask, &oldmask); for (;;) { s = getport(&lport); if (s < 0) { @@ -130,7 +132,7 @@ kcmd(sock, ahost, rport, locuser, remuser, cmd, fd2p, ticket, service, realm, "kcmd(socket): All ports in use\n"); else perror("kcmd: socket"); - sigsetmask(oldmask); + sigprocmask(SIG_SETMASK, &oldmask, NULL); return (-1); } fcntl(s, F_SETOWN, pid); @@ -170,7 +172,7 @@ kcmd(sock, ahost, rport, locuser, remuser, cmd, fd2p, ticket, service, realm, } if (errno != ECONNREFUSED) perror(hp->h_name); - sigsetmask(oldmask); + sigprocmask(SIG_SETMASK, &oldmask, NULL); return (-1); } if (fd2p == 0) { @@ -268,7 +270,7 @@ again: status = -1; goto bad2; } - sigsetmask(oldmask); + sigprocmask(SIG_SETMASK, &oldmask, NULL); *sock = s; return (KSUCCESS); bad2: @@ -276,7 +278,7 @@ bad2: (void) close(*fd2p); bad: (void) close(s); - sigsetmask(oldmask); + sigprocmask(SIG_SETMASK, &oldmask, NULL); return (status); } diff --git a/usr.bin/rlogin/rlogin.c b/usr.bin/rlogin/rlogin.c index 2a874f07941..56681a920ca 100644 --- a/usr.bin/rlogin/rlogin.c +++ b/usr.bin/rlogin/rlogin.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rlogin.c,v 1.23 2001/07/03 23:47:05 jasoni Exp $ */ +/* $OpenBSD: rlogin.c,v 1.24 2001/09/04 23:35:59 millert Exp $ */ /* $NetBSD: rlogin.c,v 1.8 1995/10/05 09:07:22 mycroft Exp $ */ /* @@ -44,7 +44,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)rlogin.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: rlogin.c,v 1.23 2001/07/03 23:47:05 jasoni Exp $"; +static char rcsid[] = "$OpenBSD: rlogin.c,v 1.24 2001/09/04 23:35:59 millert Exp $"; #endif #endif /* not lint */ @@ -128,7 +128,7 @@ struct winsize winsize; void catch_child __P((int)); void copytochild __P((int)); -__dead void doit __P((int)); +__dead void doit __P((sigset_t *)); __dead void done __P((int)); void echo __P((char)); u_int getescape __P((char *)); @@ -136,7 +136,7 @@ void lostpeer __P((int)); void mode __P((int)); void msg __P((char *)); void oob __P((int)); -int reader __P((int)); +int reader __P((sigset_t *)); void sendwindow __P((void)); void setsignal __P((int)); void sigwinch __P((int)); @@ -163,7 +163,7 @@ main(argc, argv) struct passwd *pw; struct servent *sp; struct termios tty; - int omask; + sigset_t mask, omask; int argoff, ch, dflag, one, uid; char *host, *p, *user, term[64]; struct sockaddr_storage ss; @@ -287,7 +287,10 @@ main(argc, argv) (void)signal(SIGPIPE, lostpeer); /* will use SIGUSR1 for window size hack, so hold it off */ - omask = sigblock(sigmask(SIGURG) | sigmask(SIGUSR1)); + sigemptyset(&mask); + sigaddset(&mask, SIGURG); + sigaddset(&mask, SIGUSR1); + sigprocmask(SIG_BLOCK, &mask, &omask); /* * We set SIGURG and SIGUSR1 below so that an * incoming signal will be held pending rather than being @@ -367,7 +370,7 @@ try_connect: (void)seteuid(uid); (void)setuid(uid); - doit(omask); + doit(&omask); /*NOTREACHED*/ return 0; @@ -377,7 +380,7 @@ pid_t child; void doit(omask) - int omask; + sigset_t *omask; { struct sigaction sa; @@ -419,7 +422,7 @@ doit(omask) * signals to the child. We can now unblock SIGURG and SIGUSR1 * that were set above. */ - (void)sigsetmask(omask); + (void)sigprocmask(SIG_SETMASK, omask, NULL); writer(); msg("closed connection."); done(0); @@ -430,11 +433,16 @@ void setsignal(sig) int sig; { - int omask = sigblock(sigmask(sig)); + sigset_t mask, omask; + + sigemptyset(&mask); + sigaddset(&mask, sig); + sigprocmask(SIG_BLOCK, &mask, &omask); if (signal(sig, exit) == SIG_IGN) (void)signal(sig, SIG_IGN); - (void)sigsetmask(omask); + + sigprocmask(SIG_SETMASK, &omask, NULL); } __dead void @@ -757,7 +765,7 @@ oob(signo) /* reader: read from remote: line -> 1 */ int reader(omask) - int omask; + sigset_t *omask; { pid_t pid; int n, remaining; @@ -769,7 +777,7 @@ reader(omask) ppid = getppid(); (void)fcntl(rem, F_SETOWN, pid); (void)setjmp(rcvtop); - (void)sigsetmask(omask); + (void)sigprocmask(SIG_SETMASK, omask, NULL); bufp = rcvbuf; for (;;) { while ((remaining = rcvcnt - (bufp - rcvbuf)) > 0) { diff --git a/usr.bin/rsh/rsh.c b/usr.bin/rsh/rsh.c index faa38bf262b..dd4f875e339 100644 --- a/usr.bin/rsh/rsh.c +++ b/usr.bin/rsh/rsh.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rsh.c,v 1.19 2000/02/01 03:23:37 deraadt Exp $ */ +/* $OpenBSD: rsh.c,v 1.20 2001/09/04 23:35:59 millert Exp $ */ /*- * Copyright (c) 1983, 1990 The Regents of the University of California. @@ -41,7 +41,7 @@ char copyright[] = #ifndef lint /*static char sccsid[] = "from: @(#)rsh.c 5.24 (Berkeley) 7/1/91";*/ -static char rcsid[] = "$OpenBSD: rsh.c,v 1.19 2000/02/01 03:23:37 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: rsh.c,v 1.20 2001/09/04 23:35:59 millert Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -87,7 +87,7 @@ int krcmd_mutual __P((char **, u_short, char *, char *, int *, char *, void usage __P((void)); -void talk __P((int, int, int, register int)); +void talk __P((int, sigset_t *, int, register int)); /* * rsh - remote shell @@ -103,7 +103,7 @@ main(argc, argv) extern int optind; struct passwd *pw; struct servent *sp; - int omask; + sigset_t mask, omask; int argoff, asrsh, ch, dflag, nflag, one, pid = 0, rem, uid; register char *p; char *args, *host, *user, *copyargs(); @@ -292,7 +292,11 @@ try_connect: (void)seteuid(uid); (void)setuid(uid); - omask = sigblock(sigmask(SIGINT)|sigmask(SIGQUIT)|sigmask(SIGTERM)); + sigemptyset(&mask); + sigaddset(&mask, SIGINT); + sigaddset(&mask, SIGQUIT); + sigaddset(&mask, SIGTERM); + sigprocmask(SIG_BLOCK, &mask, &omask); if (signal(SIGINT, SIG_IGN) != SIG_IGN) (void)signal(SIGINT, sendsig); if (signal(SIGQUIT, SIG_IGN) != SIG_IGN) @@ -317,7 +321,7 @@ try_connect: (void)ioctl(rem, FIONBIO, &one); } - talk(nflag, omask, pid, rem); + talk(nflag, &omask, pid, rem); if (!nflag) (void)kill(pid, SIGKILL); @@ -328,7 +332,7 @@ try_connect: void talk(nflag, omask, pid, rem) int nflag, pid; - int omask; + sigset_t *omask; register int rem; { register int cc, wc; @@ -377,7 +381,7 @@ done: exit(0); } - (void)sigsetmask(omask); + sigprocmask(SIG_SETMASK, &omask, NULL); FD_ZERO(&readfrom); FD_SET(rfd2, &readfrom); FD_SET(rem, &readfrom); diff --git a/usr.bin/systat/cmds.c b/usr.bin/systat/cmds.c index 6804c4c981a..f27ffa4bf35 100644 --- a/usr.bin/systat/cmds.c +++ b/usr.bin/systat/cmds.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmds.c,v 1.5 1997/06/23 22:21:45 millert Exp $ */ +/* $OpenBSD: cmds.c,v 1.6 2001/09/04 23:35:59 millert Exp $ */ /* $NetBSD: cmds.c,v 1.4 1996/05/10 23:16:32 thorpej Exp $ */ /*- @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)cmds.c 8.2 (Berkeley) 4/29/95"; #endif -static char rcsid[] = "$OpenBSD: cmds.c,v 1.5 1997/06/23 22:21:45 millert Exp $"; +static char rcsid[] = "$OpenBSD: cmds.c,v 1.6 2001/09/04 23:35:59 millert Exp $"; #endif /* not lint */ #include <stdlib.h> @@ -55,9 +55,12 @@ command(cmd) { register struct cmdtab *p; register char *cp; - int interval, omask; + int interval; + sigset_t mask, omask; - omask = sigblock(sigmask(SIGALRM)); + sigemptyset(&mask); + sigaddset(&mask, SIGALRM); + sigprocmask(SIG_BLOCK, &mask, &omask); for (cp = cmd; *cp && !isspace(*cp); cp++) ; if (*cp) @@ -144,7 +147,7 @@ command(cmd) if (curcmd->c_cmd == 0 || !(*curcmd->c_cmd)(cmd, cp)) error("%s: Unknown command.", cmd); done: - sigsetmask(omask); + sigprocmask(SIG_SETMASK, &omask, NULL); } struct cmdtab * diff --git a/usr.bin/systat/keyboard.c b/usr.bin/systat/keyboard.c index b7e73df32d1..e167a7b8996 100644 --- a/usr.bin/systat/keyboard.c +++ b/usr.bin/systat/keyboard.c @@ -1,4 +1,4 @@ -/* $OpenBSD: keyboard.c,v 1.6 2000/07/10 03:10:17 millert Exp $ */ +/* $OpenBSD: keyboard.c,v 1.7 2001/09/04 23:35:59 millert Exp $ */ /* $NetBSD: keyboard.c,v 1.2 1995/01/20 08:51:59 jtc Exp $ */ /*- @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)keyboard.c 8.1 (Berkeley) 6/6/93"; #endif -static char rcsid[] = "$OpenBSD: keyboard.c,v 1.6 2000/07/10 03:10:17 millert Exp $"; +static char rcsid[] = "$OpenBSD: keyboard.c,v 1.7 2001/09/04 23:35:59 millert Exp $"; #endif /* not lint */ #include <ctype.h> @@ -52,7 +52,7 @@ void keyboard() { char ch, line[80]; - int oldmask; + sigset_t mask, omask; for (;;) { col = 0; @@ -69,21 +69,23 @@ keyboard() if (ch >= 'A' && ch <= 'Z') ch += 'a' - 'A'; if (col == 0) { -#define mask(s) (1 << ((s) - 1)) - if (ch == CTRL('l')) { - oldmask = sigblock(mask(SIGALRM)); - wrefresh(curscr); - sigsetmask(oldmask); + switch (ch) { + case CTRL('l'): + case CTRL('g'): + sigemptyset(&mask); + sigaddset(&mask, SIGALRM); + sigprocmask(SIG_BLOCK, &mask, &omask); + if (ch == CTRL('l')) + wrefresh(curscr); + else + status(); + sigprocmask(SIG_SETMASK, &omask, NULL); continue; - } - if (ch == CTRL('g')) { - oldmask = sigblock(mask(SIGALRM)); - status(); - sigsetmask(oldmask); + case ':': + break; + default: continue; } - if (ch != ':') - continue; move(CMDLINE, 0); clrtoeol(); } @@ -124,9 +126,11 @@ keyboard() } } while (col == 0 || (ch != '\r' && ch != '\n')); line[col] = '\0'; - oldmask = sigblock(mask(SIGALRM)); + sigemptyset(&mask); + sigaddset(&mask, SIGALRM); + sigprocmask(SIG_BLOCK, &mask, &omask); command(line + 1); - sigsetmask(oldmask); + sigprocmask(SIG_SETMASK, &omask, NULL); } /*NOTREACHED*/ } diff --git a/usr.bin/systat/main.c b/usr.bin/systat/main.c index 0698929dc1c..004cc253236 100644 --- a/usr.bin/systat/main.c +++ b/usr.bin/systat/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.15 2001/05/04 16:48:34 ericj Exp $ */ +/* $OpenBSD: main.c,v 1.16 2001/09/04 23:35:59 millert Exp $ */ /* $NetBSD: main.c,v 1.8 1996/05/10 23:16:36 thorpej Exp $ */ /*- @@ -44,7 +44,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/6/93"; #endif -static char rcsid[] = "$OpenBSD: main.c,v 1.15 2001/05/04 16:48:34 ericj Exp $"; +static char rcsid[] = "$OpenBSD: main.c,v 1.16 2001/09/04 23:35:59 millert Exp $"; #endif /* not lint */ #include <sys/param.h> @@ -289,14 +289,14 @@ void resize(signo) int signo; { - int oldmask; + sigset_t mask, oldmask; -#define mask(s) (1 << ((s) - 1)) - oldmask = sigblock(mask(SIGALRM)); + sigemptyset(&mask); + sigaddset(&mask, SIGALRM); + sigprocmask(SIG_BLOCK, &mask, &oldmask); clearok(curscr, TRUE); wrefresh(curscr); - sigsetmask(oldmask); -#undef mask + sigprocmask(SIG_SETMASK, &oldmask, NULL); } diff --git a/usr.bin/telnet/sys_bsd.c b/usr.bin/telnet/sys_bsd.c index ba105592dad..f7a9f14281b 100644 --- a/usr.bin/telnet/sys_bsd.c +++ b/usr.bin/telnet/sys_bsd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sys_bsd.c,v 1.8 2000/10/10 15:41:10 millert Exp $ */ +/* $OpenBSD: sys_bsd.c,v 1.9 2001/09/04 23:35:59 millert Exp $ */ /* $NetBSD: sys_bsd.c,v 1.11 1996/02/28 21:04:10 thorpej Exp $ */ /* @@ -636,6 +636,9 @@ TerminalNewMode(f) tc.t_brkc = esc; #endif } else { +#ifdef SIGTSTP + sigset_t mask; +#endif /* SIGTSTP */ #ifdef SIGINFO void ayt_status(); @@ -643,11 +646,9 @@ TerminalNewMode(f) #endif #ifdef SIGTSTP (void) signal(SIGTSTP, SIG_DFL); -# ifndef SOLARIS - (void) sigsetmask(sigblock(0) & ~(1<<(SIGTSTP-1))); -# else SOLARIS - (void) sigrelse(SIGTSTP); -# endif SOLARIS + sigemptyset(&mask); + sigaddset(&mask, SIGTSTP); + sigprocmask(SIG_UNBLOCK, &mask, NULL); #endif /* SIGTSTP */ #ifndef USE_TERMIO ltc = oltc; diff --git a/usr.bin/tip/aculib/courier.c b/usr.bin/tip/aculib/courier.c index c335cbd2f48..8ee311c6b69 100644 --- a/usr.bin/tip/aculib/courier.c +++ b/usr.bin/tip/aculib/courier.c @@ -1,4 +1,4 @@ -/* $OpenBSD: courier.c,v 1.6 1997/09/01 23:24:28 deraadt Exp $ */ +/* $OpenBSD: courier.c,v 1.7 2001/09/04 23:35:59 millert Exp $ */ /* $NetBSD: courier.c,v 1.7 1997/02/11 09:24:16 mrg Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)courier.c 8.1 (Berkeley) 6/6/93"; #endif -static char rcsid[] = "$OpenBSD: courier.c,v 1.6 1997/09/01 23:24:28 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: courier.c,v 1.7 2001/09/04 23:35:59 millert Exp $"; #endif /* not lint */ /* @@ -57,7 +57,6 @@ static int connected = 0; static jmp_buf timeoutbuf, intbuf; static int coursync(), cour_connect(), cour_swallow(); void cour_nap(); -static void cour_napx(); void cour_disconnect __P((void)); @@ -343,46 +342,14 @@ cour_verbose_read() } #endif -/* - * Code stolen from /usr/src/lib/libc/gen/sleep.c - */ -#define mask(s) (1<<((s)-1)) -#define setvec(vec, a) \ - vec.sv_handler = a; vec.sv_mask = vec.sv_onstack = 0 - -static napms = 50; /* Give the courier 50 milliseconds between characters */ - -static int ringring; - +/* Give the courier 50 milliseconds between characters */ void cour_nap() { - int omask; - struct itimerval itv, oitv; - register struct itimerval *itp = &itv; - struct sigvec vec, ovec; + struct timespec ts; - timerclear(&itp->it_interval); - timerclear(&itp->it_value); - if (setitimer(ITIMER_REAL, itp, &oitv) < 0) - return; - setvec(ovec, SIG_DFL); - omask = sigblock(mask(SIGALRM)); - itp->it_value.tv_sec = napms/1000; - itp->it_value.tv_usec = ((napms%1000)*1000); - setvec(vec, cour_napx); - ringring = 0; - (void) sigvec(SIGALRM, &vec, &ovec); - (void) setitimer(ITIMER_REAL, itp, (struct itimerval *)0); - while (!ringring) - sigpause(omask &~ mask(SIGALRM)); - (void) sigvec(SIGALRM, &ovec, (struct sigvec *)0); - (void) setitimer(ITIMER_REAL, &oitv, (struct itimerval *)0); - (void) sigsetmask(omask); -} + ts.tv_sec = 0; + ts.tv_nsec = 50 * 1000000; -static void -cour_napx() -{ - ringring = 1; + nanosleep(&ts, NULL); } diff --git a/usr.bin/tip/aculib/t3000.c b/usr.bin/tip/aculib/t3000.c index e8f0972e533..947b28e0024 100644 --- a/usr.bin/tip/aculib/t3000.c +++ b/usr.bin/tip/aculib/t3000.c @@ -1,4 +1,4 @@ -/* $OpenBSD: t3000.c,v 1.5 1997/04/02 01:47:07 millert Exp $ */ +/* $OpenBSD: t3000.c,v 1.6 2001/09/04 23:35:59 millert Exp $ */ /* $NetBSD: t3000.c,v 1.5 1997/02/11 09:24:18 mrg Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)t3000.c 8.1 (Berkeley) 6/6/93"; #endif -static char rcsid[] = "$OpenBSD: t3000.c,v 1.5 1997/04/02 01:47:07 millert Exp $"; +static char rcsid[] = "$OpenBSD: t3000.c,v 1.6 2001/09/04 23:35:59 millert Exp $"; #endif /* not lint */ /* @@ -355,45 +355,14 @@ t3000_verbose_read() } #endif -/* - * Code stolen from /usr/src/lib/libc/gen/sleep.c - */ -#define mask(s) (1<<((s)-1)) -#define setvec(vec, a) \ - vec.sv_handler = a; vec.sv_mask = vec.sv_onstack = 0 - -static napms = 50; /* Give the t3000 50 milliseconds between characters */ - -static int ringring; - +/* Give the t3000 50 milliseconds between characters */ +void t3000_nap() { - int omask; - struct itimerval itv, oitv; - register struct itimerval *itp = &itv; - struct sigvec vec, ovec; + struct timespec ts; - timerclear(&itp->it_interval); - timerclear(&itp->it_value); - if (setitimer(ITIMER_REAL, itp, &oitv) < 0) - return; - setvec(ovec, SIG_DFL); - omask = sigblock(mask(SIGALRM)); - itp->it_value.tv_sec = napms/1000; - itp->it_value.tv_usec = ((napms%1000)*1000); - setvec(vec, t3000_napx); - ringring = 0; - (void) sigvec(SIGALRM, &vec, &ovec); - (void) setitimer(ITIMER_REAL, itp, (struct itimerval *)0); - while (!ringring) - sigpause(omask &~ mask(SIGALRM)); - (void) sigvec(SIGALRM, &ovec, (struct sigvec *)0); - (void) setitimer(ITIMER_REAL, &oitv, (struct itimerval *)0); - (void) sigsetmask(omask); -} + ts.tv_sec = 0; + ts.tv_nsec = 50 * 1000000; -static void -t3000_napx() -{ - ringring = 1; + nanosleep(&ts, NULL); } diff --git a/usr.bin/tip/tipout.c b/usr.bin/tip/tipout.c index 98bbab4419a..45e2f2b0802 100644 --- a/usr.bin/tip/tipout.c +++ b/usr.bin/tip/tipout.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tipout.c,v 1.6 1997/09/01 23:24:27 deraadt Exp $ */ +/* $OpenBSD: tipout.c,v 1.7 2001/09/04 23:35:59 millert Exp $ */ /* $NetBSD: tipout.c,v 1.5 1996/12/29 10:34:12 cgd Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)tipout.c 8.1 (Berkeley) 6/6/93"; #endif -static char rcsid[] = "$OpenBSD: tipout.c,v 1.6 1997/09/01 23:24:27 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: tipout.c,v 1.7 2001/09/04 23:35:59 millert Exp $"; #endif /* not lint */ #include "tip.h" @@ -125,7 +125,7 @@ tipout() register char *cp; register int cnt; extern int errno; - int omask; + sigset_t mask, omask; signal(SIGINT, SIG_IGN); signal(SIGQUIT, SIG_IGN); @@ -135,19 +135,27 @@ tipout() signal(SIGHUP, intTERM); /* for dial-ups */ signal(SIGSYS, intSYS); /* beautify toggle */ (void) setjmp(sigbuf); - for (omask = 0;; sigsetmask(omask)) { + sigprocmask(SIG_BLOCK, NULL, &omask); + for (;;) { + sigprocmask(SIG_SETMASK, &omask, NULL); cnt = read(FD, buf, BUFSIZ); if (cnt <= 0) { /* lost carrier */ if (cnt < 0 && errno == EIO) { - sigblock(sigmask(SIGTERM)); + sigemptyset(&mask); + sigaddset(&mask, SIGTERM); + sigprocmask(SIG_BLOCK, &mask, NULL); intTERM(); /*NOTREACHED*/ } continue; } -#define ALLSIGS sigmask(SIGEMT)|sigmask(SIGTERM)|sigmask(SIGIOT)|sigmask(SIGSYS) - omask = sigblock(ALLSIGS); + sigemptyset(&mask); + sigaddset(&mask, SIGEMT); + sigaddset(&mask, SIGTERM); + sigaddset(&mask, SIGIOT); + sigaddset(&mask, SIGSYS); + sigprocmask(SIG_BLOCK, &mask, NULL); for (cp = buf; cp < buf + cnt; cp++) *cp &= STRIP_PAR; write(1, buf, cnt); diff --git a/usr.bin/top/top.c b/usr.bin/top/top.c index 78e99f65090..04f82233d6b 100644 --- a/usr.bin/top/top.c +++ b/usr.bin/top/top.c @@ -1,4 +1,4 @@ -/* $OpenBSD: top.c,v 1.9 2001/07/27 17:13:42 deraadt Exp $ */ +/* $OpenBSD: top.c,v 1.10 2001/09/04 23:35:59 millert Exp $ */ const char copyright[] = "Copyright (c) 1984 through 1996, William LeFebvre"; @@ -25,8 +25,6 @@ const char copyright[] = "Copyright (c) 1984 through 1996, William LeFebvre"; * The following preprocessor variables, when defined, are used to * distinguish between different Unix implementations: * - * SIGHOLD - use SVR4 sighold function when defined - * SIGRELSE - use SVR4 sigrelse function when defined * FD_SET - macros FD_SET and FD_ZERO are used when defined */ @@ -56,9 +54,6 @@ const char copyright[] = "Copyright (c) 1984 through 1996, William LeFebvre"; /* The buffer that stdio will use */ char stdoutbuf[Buffersize]; -/* build Signal masks */ -#define Smask(s) (1 << ((s) - 1)) - /* imported from screen.c */ extern int overstrike; @@ -120,7 +115,7 @@ char *argv[]; static char tempbuf1[50]; static char tempbuf2[50]; - int old_sigmask; /* only used for BSD-style signals */ + sigset_t mask, oldmask; int topn = Default_TOPN; int delay = Default_DELAY; int displays = 0; /* indicates unspecified */ @@ -457,14 +452,12 @@ Usage: %s [-ISbinqu] [-d x] [-s x] [-o field] [-U username] [number]\n", displays = smart_terminal ? Infinity : 1; } - /* hold interrupt signals while setting up the screen and the handlers */ -#ifdef SIGHOLD - sighold(SIGINT); - sighold(SIGQUIT); - sighold(SIGTSTP); -#else - old_sigmask = sigblock(Smask(SIGINT) | Smask(SIGQUIT) | Smask(SIGTSTP)); -#endif + /* block interrupt signals while setting up the screen and the handlers */ + sigemptyset(&mask); + sigaddset(&mask, SIGINT); + sigaddset(&mask, SIGQUIT); + sigaddset(&mask, SIGTSTP); + sigprocmask(SIG_BLOCK, &mask, &oldmask); init_screen(); (void) signal(SIGINT, leave); (void) signal(SIGQUIT, leave); @@ -472,13 +465,7 @@ Usage: %s [-ISbinqu] [-d x] [-s x] [-o field] [-U username] [number]\n", #ifdef SIGWINCH (void) signal(SIGWINCH, winch); #endif -#ifdef SIGRELSE - sigrelse(SIGINT); - sigrelse(SIGQUIT); - sigrelse(SIGTSTP); -#else - (void) sigsetmask(old_sigmask); -#endif + sigprocmask(SIG_SETMASK, &oldmask, NULL); if (warnings) { fputs("....", stderr); @@ -640,11 +627,9 @@ restart: (void) signal(SIGTSTP, SIG_DFL); /* unblock the signal and send ourselves one */ -#ifdef SIGRELSE - sigrelse(SIGTSTP); -#else - (void) sigsetmask(sigblock(0) & ~(1 << (SIGTSTP - 1))); -#endif + sigemptyset(&mask); + sigaddset(&mask, SIGTSTP); + sigprocmask(SIG_UNBLOCK, &mask, NULL); (void) kill(0, SIGTSTP); /* reset the signal handler */ diff --git a/usr.bin/wall/ttymsg.c b/usr.bin/wall/ttymsg.c index f49fdec4912..00ff4b545f9 100644 --- a/usr.bin/wall/ttymsg.c +++ b/usr.bin/wall/ttymsg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ttymsg.c,v 1.6 1998/11/18 16:47:01 deraadt Exp $ */ +/* $OpenBSD: ttymsg.c,v 1.7 2001/09/04 23:35:59 millert Exp $ */ /* $NetBSD: ttymsg.c,v 1.3 1994/11/17 07:17:55 jtc Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)ttymsg.c 8.2 (Berkeley) 11/16/93"; #endif -static char rcsid[] = "$OpenBSD: ttymsg.c,v 1.6 1998/11/18 16:47:01 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: ttymsg.c,v 1.7 2001/09/04 23:35:59 millert Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -74,6 +74,7 @@ ttymsg(iov, iovcnt, line, tmout) struct iovec localiov[6]; int forked = 0; struct stat st; + sigset_t mask; if (iovcnt > sizeof(localiov) / sizeof(localiov[0])) return ("too many iov's (change code in wall/ttymsg.c)"); @@ -159,7 +160,8 @@ ttymsg(iov, iovcnt, line, tmout) /* wait at most tmout seconds */ (void) signal(SIGALRM, SIG_DFL); (void) signal(SIGTERM, SIG_DFL); /* XXX */ - (void) sigsetmask(0); + (void) sigemptyset(&mask); + (void) sigprocmask(SIG_SETMASK, &mask, NULL); (void) alarm((u_int)tmout); (void) fcntl(fd, O_NONBLOCK, &off); continue; diff --git a/usr.sbin/amd/amd/nfs_start.c b/usr.sbin/amd/amd/nfs_start.c index b7159f159d5..12bb9ddc04e 100644 --- a/usr.sbin/amd/amd/nfs_start.c +++ b/usr.sbin/amd/amd/nfs_start.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * from: @(#)nfs_start.c 8.1 (Berkeley) 6/6/93 - * $Id: nfs_start.c,v 1.4 2001/03/02 06:22:04 deraadt Exp $ + * $Id: nfs_start.c,v 1.5 2001/09/04 23:35:59 millert Exp $ */ #include "am.h" @@ -65,8 +65,6 @@ SVCXPRT *nfsxprt; extern int fwd_sock; int max_fds = -1; -#define MASKED_SIGS (sigmask(SIGINT)|sigmask(SIGTERM)|sigmask(SIGCHLD)|sigmask(SIGHUP)) - #ifdef DEBUG /* * Check that we are not burning resources @@ -102,8 +100,9 @@ static char *max_mem = 0; } #endif /* DEBUG */ -static int do_select(smask, fds, fdp, tvp) -int smask; +static int do_select(mask, omask, fds, fdp, tvp) +sigset_t *mask; +sigset_t *omask; int fds; fd_set *fdp; struct timeval *tvp; @@ -133,7 +132,7 @@ struct timeval *tvp; * occurs, then it will cause a longjmp * up above. */ - (void) sigsetmask(smask); + sigprocmask(SIG_SETMASK, omask, NULL); /* * Wait for input */ @@ -142,7 +141,7 @@ struct timeval *tvp; } - (void) sigblock(MASKED_SIGS); + sigprocmask(SIG_BLOCK, mask, NULL); /* * Perhaps reload the cache? @@ -201,7 +200,14 @@ static int rpc_pending_now() static serv_state run_rpc(P_void) { - int smask = sigblock(MASKED_SIGS); + sigset_t mask, omask; + + sigemptyset(&mask); + sigaddset(&mask, SIGINT); + sigaddset(&mask, SIGTERM); + sigaddset(&mask, SIGCHLD); + sigaddset(&mask, SIGHUP); + sigprocmask(SIG_BLOCK, &mask, &omask); next_softclock = clocktime(); @@ -283,7 +289,7 @@ static serv_state run_rpc(P_void) dlog("Select waits for Godot"); #endif /* DEBUG */ - nsel = do_select(smask, fdsn + 1, fdsp, &tvv); + nsel = do_select(mask, omask, fdsn + 1, fdsp, &tvv); switch (nsel) { @@ -349,7 +355,7 @@ static serv_state run_rpc(P_void) free(fdsp); } - (void) sigsetmask(smask); + sigprocmask(SIG_SETMASK, &omask, NULL); if (amd_state == Quit) amd_state = Done; diff --git a/usr.sbin/amd/amd/sched.c b/usr.sbin/amd/amd/sched.c index 6c03a1489a5..64328aa6a7d 100644 --- a/usr.sbin/amd/amd/sched.c +++ b/usr.sbin/amd/amd/sched.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * from: @(#)sched.c 8.1 (Berkeley) 6/6/93 - * $Id: sched.c,v 1.3 2001/03/02 06:22:04 deraadt Exp $ + * $Id: sched.c,v 1.4 2001/09/04 23:35:59 millert Exp $ */ /* @@ -110,14 +110,16 @@ cb_fun cf; voidp ca; { pjob *p = sched_job(cf, ca); - int mask; + sigset_t mask, omask; p->wchan = (voidp) p; - mask = sigblock(sigmask(SIGCHLD)); + sigemptyset(&mask); + sigaddset(&mask, SIGCHLD); + sigprocmask(SIG_BLOCK, &mask, &omask); if ((p->pid = background())) { - sigsetmask(mask); + sigprocmask(SIG_SETMASK, &omask, NULL); return; } @@ -275,51 +277,3 @@ void do_task_notify(P_void) free((voidp) p); } } - -#ifdef HAS_SVR3_SIGNALS -/* - * 4.2 signal library based on svr3 (4.1+ bsd) interface - * From Stephen C. Pope <scp@acl.lanl.gov). - */ - -static int current_mask = 0; - -int sigblock(mask) -int mask; -{ - int sig; - int m; - int oldmask; - - oldmask = current_mask; - for ( sig = 1, m = 1; sig <= MAXSIG; sig++, m <<= 1 ) { - if (mask & m) { - sighold(sig); - current_mask |= m; - } - } - return oldmask; -} - -int sigsetmask(mask) -int mask; -{ - int sig; - int m; - int oldmask; - - oldmask = current_mask; - for ( sig = 1, m = 1; sig <= MAXSIG; sig++, m <<= 1 ) { - if (mask & m) { - sighold(sig); - current_mask |= m; - } - else { - sigrelse(sig); - current_mask &= ~m; - } - } - return oldmask; -} - -#endif /* HAS_SVR3_SIGNALS */ diff --git a/usr.sbin/edquota/edquota.c b/usr.sbin/edquota/edquota.c index f3c41296c78..64de9f771d3 100644 --- a/usr.sbin/edquota/edquota.c +++ b/usr.sbin/edquota/edquota.c @@ -42,7 +42,7 @@ static char copyright[] = #ifndef lint /*static char sccsid[] = "from: @(#)edquota.c 8.1 (Berkeley) 6/6/93";*/ -static char *rcsid = "$Id: edquota.c,v 1.27 2001/01/15 05:17:17 angelos Exp $"; +static char *rcsid = "$Id: edquota.c,v 1.28 2001/09/04 23:35:59 millert Exp $"; #endif /* not lint */ /* @@ -361,11 +361,10 @@ int editit(tmpfile) char *tmpfile; { - int omask; int pid, stat, xpid; char *argp[] = {"sh", "-c", NULL, NULL}; - register char *ed; - char *p; + char *ed, *p; + sigset_t mask, omask; if ((ed = getenv("EDITOR")) == (char *)0) ed = _PATH_VI; @@ -375,7 +374,11 @@ editit(tmpfile) (void)sprintf(p, "%s %s", ed, tmpfile); argp[2] = p; - omask = sigblock(sigmask(SIGINT)|sigmask(SIGQUIT)|sigmask(SIGHUP)); + sigemptyset(&mask); + sigaddset(&mask, SIGINT); + sigaddset(&mask, SIGQUIT); + sigaddset(&mask, SIGHUP); + sigprocmask(SIG_SETMASK, &mask, &omask); top: if ((pid = fork()) < 0) { if (errno == EPROCLIM) { @@ -392,7 +395,7 @@ editit(tmpfile) return(0); } if (pid == 0) { - sigsetmask(omask); + sigprocmask(SIG_SETMASK, &omask, NULL); setgid(getgid()); setuid(getuid()); execv(_PATH_BSHELL, argp); @@ -406,7 +409,7 @@ editit(tmpfile) else if (WIFEXITED(stat)) break; } - sigsetmask(omask); + sigprocmask(SIG_SETMASK, &omask, NULL); if (!WIFEXITED(stat) || WEXITSTATUS(stat) != 0) return(0); return(1); diff --git a/usr.sbin/inetd/inetd.c b/usr.sbin/inetd/inetd.c index 8c344920dbd..f1c30f1e3e8 100644 --- a/usr.sbin/inetd/inetd.c +++ b/usr.sbin/inetd/inetd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: inetd.c,v 1.84 2001/09/03 21:22:38 pjanzen Exp $ */ +/* $OpenBSD: inetd.c,v 1.85 2001/09/04 23:35:59 millert Exp $ */ /* $NetBSD: inetd.c,v 1.11 1996/02/22 11:14:41 mycroft Exp $ */ /* * Copyright (c) 1983,1991 The Regents of the University of California. @@ -41,7 +41,7 @@ char copyright[] = #ifndef lint /*static char sccsid[] = "from: @(#)inetd.c 5.30 (Berkeley) 6/3/91";*/ -static char rcsid[] = "$OpenBSD: inetd.c,v 1.84 2001/09/03 21:22:38 pjanzen Exp $"; +static char rcsid[] = "$OpenBSD: inetd.c,v 1.85 2001/09/04 23:35:59 millert Exp $"; #endif /* not lint */ /* @@ -174,8 +174,6 @@ static char rcsid[] = "$OpenBSD: inetd.c,v 1.84 2001/09/03 21:22:38 pjanzen Exp #define CNT_INTVL 60 /* servers in CNT_INTVL sec. */ #define RETRYTIME (60*10) /* retry after bind or server fail */ -#define SIGBLOCK (sigmask(SIGCHLD)|sigmask(SIGHUP)|sigmask(SIGALRM)) - void config __P((int)); void doconfig __P((void)); void reap __P((int)); @@ -184,16 +182,18 @@ void retry __P((int)); void doretry __P((void)); void goaway __P((int)); -int debug = 0; -int nsock, maxsock; +int debug = 0; +int nsock, maxsock; fd_set *allsockp; -int allsockn; -int toomany = TOOMANY; -int options; -int timingout; -struct servent *sp; +int allsockn; +int toomany = TOOMANY; +int options; +int timingout; +struct servent *sp; char *curdom; -uid_t uid; +uid_t uid; +sigset_t blockmask; +sigset_t emptymask; #ifndef OPEN_MAX #define OPEN_MAX 64 @@ -412,6 +412,12 @@ main(argc, argv, envp) } #endif + sigemptyset(&emptymask); + sigemptyset(&blockmask); + sigaddset(&blockmask, SIGCHLD); + sigaddset(&blockmask, SIGHUP); + sigaddset(&blockmask, SIGALRM); + memset((char *)&sa, 0, sizeof(sa)); sigemptyset(&sa.sa_mask); sigaddset(&sa.sa_mask, SIGALRM); @@ -446,13 +452,13 @@ main(argc, argv, envp) int n, ctrl = -1; if (nsock == 0) { - (void) sigblock(SIGBLOCK); + (void) sigprocmask(SIG_BLOCK, &blockmask, NULL); while (nsock == 0) { if (wantretry || wantconfig || wantreap) break; - sigpause(0L); + sigsuspend(&emptymask); } - (void) sigsetmask(0L); + (void) sigprocmask(SIG_SETMASK, &emptymask, NULL); } if (wantretry || wantconfig || wantreap) { @@ -525,7 +531,7 @@ main(argc, argv, envp) } } else ctrl = sep->se_fd; - (void) sigblock(SIGBLOCK); + (void) sigprocmask(SIG_BLOCK, &blockmask, NULL); pid = 0; dofork = (sep->se_bi == 0 || sep->se_bi->bi_fork); if (dofork) { @@ -565,7 +571,8 @@ main(argc, argv, envp) sep->se_fd = -1; sep->se_count = 0; nsock--; - sigsetmask(0L); + sigprocmask(SIG_SETMASK, &emptymask, + NULL); if (!timingout) { timingout = 1; alarm(RETRYTIME); @@ -579,7 +586,7 @@ main(argc, argv, envp) syslog(LOG_ERR, "fork: %m"); if (!sep->se_wait && sep->se_socktype == SOCK_STREAM) close(ctrl); - sigsetmask(0L); + sigprocmask(SIG_SETMASK, &emptymask, NULL); sleep(1); continue; } @@ -588,7 +595,7 @@ main(argc, argv, envp) FD_CLR(sep->se_fd, allsockp); nsock--; } - sigsetmask(0L); + sigprocmask(SIG_SETMASK, &emptymask, NULL); if (pid == 0) { if (sep->se_bi) (*sep->se_bi->bi_fn)(ctrl, sep); @@ -774,9 +781,9 @@ void doconfig(void) { register struct servtab *sep, *cp, **sepp; - int omask; int n, add; char protoname[10]; + sigset_t omask; if (!setconfig()) { syslog(LOG_ERR, "%s: %m", CONFIG); @@ -795,7 +802,7 @@ doconfig(void) #define SWAP(type, a, b) {type c=(type)a; (type)a=(type)b; (type)b=(type)c;} - omask = sigblock(SIGBLOCK); + sigprocmask(SIG_BLOCK, &blockmask, &omask); /* * sep->se_wait may be holding the pid of a daemon * that we're waiting for. If so, don't overwrite @@ -816,7 +823,7 @@ doconfig(void) unregister_rpc(sep); sep->se_rpcversl = cp->se_rpcversl; sep->se_rpcversh = cp->se_rpcversh; - sigsetmask(omask); + sigprocmask(SIG_SETMASK, &omask, NULL); freeconfig(cp); add = 1; } else { @@ -968,7 +975,7 @@ doconfig(void) /* * Purge anything not looked at above. */ - omask = sigblock(SIGBLOCK); + sigprocmask(SIG_BLOCK, &blockmask, &omask); sepp = &servtab; while ((sep = *sepp)) { if (sep->se_checked) { @@ -990,7 +997,7 @@ doconfig(void) freeconfig(sep); free((char *)sep); } - (void) sigsetmask(omask); + sigprocmask(SIG_SETMASK, &omask, NULL); } void @@ -1179,7 +1186,7 @@ enter(cp) struct servtab *cp; { register struct servtab *sep; - int omask; + sigset_t omask; sep = (struct servtab *)malloc(sizeof (*sep)); if (sep == NULL) { @@ -1189,10 +1196,10 @@ enter(cp) *sep = *cp; sep->se_fd = -1; sep->se_rpcprog = -1; - omask = sigblock(SIGBLOCK); + sigprocmask(SIG_BLOCK, &blockmask, &omask); sep->se_next = servtab; servtab = sep; - sigsetmask(omask); + sigprocmask(SIG_SETMASK, &omask, NULL); return (sep); } diff --git a/usr.sbin/lpr/lpd/lpd.c b/usr.sbin/lpr/lpd/lpd.c index 9123a23143d..ed7470d1a74 100644 --- a/usr.sbin/lpr/lpd/lpd.c +++ b/usr.sbin/lpr/lpd/lpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lpd.c,v 1.19 2001/08/30 23:24:46 millert Exp $ */ +/* $OpenBSD: lpd.c,v 1.20 2001/09/04 23:35:59 millert Exp $ */ /* $NetBSD: lpd.c,v 1.7 1996/04/24 14:54:06 mrg Exp $ */ /* @@ -45,7 +45,7 @@ static const char copyright[] = #if 0 static const char sccsid[] = "@(#)lpd.c 8.7 (Berkeley) 5/10/95"; #else -static const char rcsid[] = "$OpenBSD: lpd.c,v 1.19 2001/08/30 23:24:46 millert Exp $"; +static const char rcsid[] = "$OpenBSD: lpd.c,v 1.20 2001/09/04 23:35:59 millert Exp $"; #endif #endif /* not lint */ @@ -123,11 +123,11 @@ main(argc, argv) int argc; char **argv; { - int f, funix, finet, options, fromlen; + int f, lfd, funix, finet, options, fromlen; fd_set defreadfds; struct sockaddr_un un, fromunix; struct sockaddr_in sin, frominet; - int omask, lfd; + sigset_t mask, omask; euid = geteuid(); /* these shouldn't be different */ uid = getuid(); @@ -196,8 +196,12 @@ main(argc, argv) syslog(LOG_ERR, "socket: %m"); exit(1); } -#define mask(s) (1 << ((s) - 1)) - omask = sigblock(mask(SIGHUP)|mask(SIGINT)|mask(SIGQUIT)|mask(SIGTERM)); + sigemptyset(&mask); + sigaddset(&mask, SIGHUP); + sigaddset(&mask, SIGINT); + sigaddset(&mask, SIGQUIT); + sigaddset(&mask, SIGTERM); + sigprocmask(SIG_BLOCK, &mask, &omask); (void) umask(07); signal(SIGHUP, mcleanup); signal(SIGINT, mcleanup); @@ -214,7 +218,7 @@ main(argc, argv) exit(1); } (void) umask(0); - sigsetmask(omask); + sigprocmask(SIG_SETMASK, &omask, NULL); FD_ZERO(&defreadfds); FD_SET(funix, &defreadfds); listen(funix, 5); diff --git a/usr.sbin/mrouted/main.c b/usr.sbin/mrouted/main.c index eb4d5467dfe..d1e2ce4be89 100644 --- a/usr.sbin/mrouted/main.c +++ b/usr.sbin/mrouted/main.c @@ -33,7 +33,7 @@ #ifndef lint static char rcsid[] = - "@(#) $Id: main.c,v 1.5 2001/03/09 03:24:07 deraadt Exp $"; + "@(#) $Id: main.c,v 1.6 2001/09/04 23:35:59 millert Exp $"; #endif extern char *configfilename; @@ -98,7 +98,6 @@ main(argc, argv) char *argv[]; { register int recvlen; - register int omask; int dummy; FILE *fp; struct timeval tv; @@ -106,6 +105,7 @@ main(argc, argv) int vers; fd_set rfds, readers; int nfds, n, i; + sigset_t mask, omask; #ifdef SNMP struct timeval timeout, *tvp = &timeout; struct timeval sched, *svp = &sched, now, *nvp = &now; @@ -314,9 +314,6 @@ usage: fprintf(stderr, */ dummy = 0; for(;;) { -#ifdef SYSV - sigset_t block, oblock; -#endif bcopy((char *)&readers, (char *)&rfds, sizeof(rfds)); #ifdef SNMP gettimeofday(nvp, 0); @@ -358,20 +355,12 @@ usage: fprintf(stderr, if (errno != EINTR) log(LOG_ERR, errno, "recvfrom"); continue; } -#ifdef SYSV - (void)sigemptyset(&block); - (void)sigaddset(&block, SIGALRM); - if (sigprocmask(SIG_BLOCK, &block, &oblock) < 0) + (void)sigemptyset(&mask); + (void)sigaddset(&mask, SIGALRM); + if (sigprocmask(SIG_BLOCK, &mask, &omask) < 0) log(LOG_ERR, errno, "sigprocmask"); -#else - omask = sigblock(sigmask(SIGALRM)); -#endif accept_igmp(recvlen); -#ifdef SYSV - (void)sigprocmask(SIG_SETMASK, &oblock, (sigset_t *)NULL); -#else - (void)sigsetmask(omask); -#endif + (void)sigprocmask(SIG_SETMASK, &omask, NULL); } for (i = 0; i < nhandlers; i++) { @@ -591,24 +580,17 @@ static void restart(i) int i; { - register int omask; -#ifdef SYSV - sigset_t block, oblock; -#endif + sigset_t mask, omask; log(LOG_NOTICE, 0, "%s restart", versionstring); /* * reset all the entries */ -#ifdef SYSV - (void)sigemptyset(&block); - (void)sigaddset(&block, SIGALRM); - if (sigprocmask(SIG_BLOCK, &block, &oblock) < 0) + (void)sigemptyset(&mask); + (void)sigaddset(&mask, SIGALRM); + if (sigprocmask(SIG_BLOCK, &mask, &omask) < 0) log(LOG_ERR, errno, "sigprocmask"); -#else - omask = sigblock(sigmask(SIGALRM)); -#endif free_all_prunes(); free_all_routes(); stop_all_vifs(); @@ -629,11 +611,7 @@ restart(i) k_init_dvmrp(); /* enable DVMRP routing in kernel */ init_installvifs(); -#ifdef SYSV - (void)sigprocmask(SIG_SETMASK, &oblock, (sigset_t *)NULL); -#else - (void)sigsetmask(omask); -#endif + (void)sigprocmask(SIG_SETMASK, &omask, NULL); } #define LOG_MAX_MSGS 20 /* if > 20/minute then shut up for a while */ diff --git a/usr.sbin/mrouted/rsrr.c b/usr.sbin/mrouted/rsrr.c index 01ab9cc0fe5..0b736b8aa33 100644 --- a/usr.sbin/mrouted/rsrr.c +++ b/usr.sbin/mrouted/rsrr.c @@ -117,8 +117,8 @@ rsrr_read(f, rfd) int f; fd_set *rfd; { - register int rsrr_recvlen; - register int omask; + int rsrr_recvlen; + sigset_t mask, omask; bzero((char *) &client_addr, sizeof(client_addr)); rsrr_recvlen = recvfrom(rsrr_socket, rsrr_recv_buf, sizeof(rsrr_recv_buf), @@ -129,9 +129,11 @@ rsrr_read(f, rfd) return; } /* Use of omask taken from main() */ - omask = sigblock(sigmask(SIGALRM)); + sigemptyset(&mask); + sigaddset(&mask, SIGALRM); + sigprocmask(SIG_BLOCK, &mask, &omask); rsrr_accept(rsrr_recvlen); - (void)sigsetmask(omask); + sigprocmask(SIG_SETMASK, &omask, NULL); } /* Accept a message from the reservation protocol and take diff --git a/usr.sbin/ppp/ppp/lcp.c b/usr.sbin/ppp/ppp/lcp.c index a76f0928d7e..9980ebd9641 100644 --- a/usr.sbin/ppp/ppp/lcp.c +++ b/usr.sbin/ppp/ppp/lcp.c @@ -25,7 +25,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $OpenBSD: lcp.c,v 1.31 2001/08/19 23:22:18 brian Exp $ + * $OpenBSD: lcp.c,v 1.32 2001/09/04 23:35:59 millert Exp $ */ #include <sys/param.h> @@ -968,13 +968,16 @@ LcpDecodeConfig(struct fsm *fp, u_char *cp, int plen, int mode_type, if (lcp->want_magic) { /* Validate magic number */ if (magic == lcp->want_magic) { + sigset_t emptyset; + log_Printf(LogLCP, "Magic is same (%08lx) - %d times\n", (u_long)magic, ++lcp->LcpFailedMagic); lcp->want_magic = GenerateMagic(); memcpy(dec->nakend, cp, 6); dec->nakend += 6; ualarm(TICKUNIT * (4 + 4 * lcp->LcpFailedMagic), 0); - sigpause(0); + sigemptyset(&emptyset); + sigsuspend(&emptyset); } else { lcp->his_magic = magic; memcpy(dec->ackend, cp, length); diff --git a/usr.sbin/ppp/ppp/timer.c b/usr.sbin/ppp/ppp/timer.c index b701abe7e2f..67a3de36a85 100644 --- a/usr.sbin/ppp/ppp/timer.c +++ b/usr.sbin/ppp/ppp/timer.c @@ -25,7 +25,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $OpenBSD: timer.c,v 1.9 2001/06/13 21:33:42 brian Exp $ + * $OpenBSD: timer.c,v 1.10 2001/09/04 23:35:59 millert Exp $ */ #include <errno.h> @@ -63,11 +63,13 @@ tState2Nam(u_int state) void timer_Stop(struct pppTimer *tp) { - int omask; + sigset_t mask, omask; - omask = sigblock(sigmask(SIGALRM)); + sigemptyset(&mask); + sigaddset(&mask, SIGALRM); + sigprocmask(SIG_BLOCK, &mask, &omask); StopTimerNoBlock(tp); - sigsetmask(omask); + sigprocmask(SIG_SETMASK, &omask, NULL); } void @@ -76,16 +78,18 @@ timer_Start(struct pppTimer *tp) struct itimerval itimer; struct pppTimer *t, *pt; u_long ticks = 0; - int omask; + sigset_t mask, omask; - omask = sigblock(sigmask(SIGALRM)); + sigemptyset(&mask); + sigaddset(&mask, SIGALRM); + sigprocmask(SIG_BLOCK, &mask, &omask); if (tp->state != TIMER_STOPPED) StopTimerNoBlock(tp); if (tp->load == 0) { log_Printf(LogTIMER, "%s timer[%p] has 0 load!\n", tp->name, tp); - sigsetmask(omask); + sigprocmask(SIG_SETMASK, &omask, NULL); return; } @@ -121,7 +125,7 @@ timer_Start(struct pppTimer *tp) if (t) t->rest -= tp->rest; - sigsetmask(omask); + sigprocmask(SIG_SETMASK, &omask, NULL); } static void diff --git a/usr.sbin/rbootd/parseconf.c b/usr.sbin/rbootd/parseconf.c index b40b0dac057..db927d08f6e 100644 --- a/usr.sbin/rbootd/parseconf.c +++ b/usr.sbin/rbootd/parseconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: parseconf.c,v 1.4 2001/01/17 00:33:03 pjanzen Exp $ */ +/* $OpenBSD: parseconf.c,v 1.5 2001/09/04 23:35:59 millert Exp $ */ /* $NetBSD: parseconf.c,v 1.4 1995/10/06 05:12:16 thorpej Exp $ */ /* @@ -49,7 +49,7 @@ #ifndef lint /*static char sccsid[] = "@(#)parseconf.c 8.1 (Berkeley) 6/4/93";*/ -static char rcsid[] = "$OpenBSD: parseconf.c,v 1.4 2001/01/17 00:33:03 pjanzen Exp $"; +static char rcsid[] = "$OpenBSD: parseconf.c,v 1.5 2001/09/04 23:35:59 millert Exp $"; #endif /* not lint */ #include <sys/param.h> @@ -90,7 +90,8 @@ ParseConfig() char line[C_LINELEN]; register char *cp, *bcp; register int i, j; - int omask, linecnt = 0; + int linecnt = 0; + sigset_t mask, omask; if (BootAny) /* ignore config file */ return(1); @@ -110,7 +111,9 @@ ParseConfig() * this could have unexpected results if the server was HUP'd * whilst reconfiguring. Hence, it is done here. */ - omask = sigblock(sigmask(SIGHUP)); + sigemptyset(&mask); + sigaddset(&mask, SIGHUP); + sigprocmask(SIG_BLOCK, &mask, &omask); /* * GETSTR positions `bcp' at the start of the current token, @@ -212,7 +215,7 @@ ParseConfig() (void) fclose(fp); /* close config file */ - (void) sigsetmask(omask); /* reset signal mask */ + sigprocmask(SIG_SETMASK, &omask, NULL); /* reset signal mask */ return(1); /* return success */ } diff --git a/usr.sbin/rbootd/rbootd.c b/usr.sbin/rbootd/rbootd.c index 649d6e94680..b55afe53670 100644 --- a/usr.sbin/rbootd/rbootd.c +++ b/usr.sbin/rbootd/rbootd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rbootd.c,v 1.7 2001/01/19 17:53:18 deraadt Exp $ */ +/* $OpenBSD: rbootd.c,v 1.8 2001/09/04 23:35:59 millert Exp $ */ /* $NetBSD: rbootd.c,v 1.5 1995/10/06 05:12:17 thorpej Exp $ */ /* @@ -55,7 +55,7 @@ static char copyright[] = #ifndef lint /*static char sccsid[] = "@(#)rbootd.c 8.1 (Berkeley) 6/4/93";*/ -static char rcsid[] = "$OpenBSD: rbootd.c,v 1.7 2001/01/19 17:53:18 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: rbootd.c,v 1.8 2001/09/04 23:35:59 millert Exp $"; #endif /* not lint */ #include <sys/param.h> @@ -79,8 +79,9 @@ main(argc, argv) int argc; char *argv[]; { - int c, fd, omask, maxfds; + int c, fd, maxfds; fd_set rset; + sigset_t hmask, omask; /* * Close any open file descriptors. @@ -201,7 +202,9 @@ main(argc, argv) /* * Initial configuration. */ - omask = sigblock(sigmask(SIGHUP)); /* prevent reconfig's */ + sigemptyset(&hmask); + sigaddset(&hmask, SIGHUP); + sigprocmask(SIG_BLOCK, &hmask, &omask); /* prevent reconfig's */ if (GetBootFiles() == 0) /* get list of boot files */ Exit(0); if (ParseConfig() == 0) /* parse config file */ @@ -214,7 +217,7 @@ main(argc, argv) */ fd = BpfOpen(); - (void) sigsetmask(omask); /* allow reconfig's */ + sigprocmask(SIG_SETMASK, &omask, NULL); /* allow reconfig's */ /* * Main loop: receive a packet, determine where it came from, @@ -259,7 +262,7 @@ main(argc, argv) if (DbgFp != NULL) /* display packet */ DispPkt(&rconn,DIR_RCVD); - omask = sigblock(sigmask(SIGHUP)); + sigprocmask(SIG_BLOCK, &hmask, &omask); /* * If we do not restrict service, set the @@ -274,13 +277,13 @@ main(argc, argv) syslog(LOG_INFO, "%s: boot packet ignored", EnetStr(&rconn)); - (void) sigsetmask(omask); + sigprocmask(SIG_SETMASK, &omask, NULL); continue; } ProcessPacket(&rconn,client); - (void) sigsetmask(omask); + sigprocmask(SIG_SETMASK, &omask, NULL); } } } diff --git a/usr.sbin/sliplogin/sliplogin.c b/usr.sbin/sliplogin/sliplogin.c index 69af6fbf095..2173f916c87 100644 --- a/usr.sbin/sliplogin/sliplogin.c +++ b/usr.sbin/sliplogin/sliplogin.c @@ -39,7 +39,7 @@ char copyright[] = #ifndef lint /*static char sccsid[] = "from: @(#)sliplogin.c 5.6 (Berkeley) 3/2/91";*/ -static char rcsid[] = "$Id: sliplogin.c,v 1.14 2001/07/27 20:34:36 pvalchev Exp $"; +static char rcsid[] = "$Id: sliplogin.c,v 1.15 2001/09/04 23:35:59 millert Exp $"; #endif /* not lint */ /* @@ -217,6 +217,7 @@ main(argc, argv) struct sgttyb tty, otty; #endif char logincmd[2*BUFSIZ+32]; + sigset_t emptyset; extern uid_t getuid(); environ = restricted_environ; /* minimal protection for system() */ @@ -378,8 +379,9 @@ main(argc, argv) /* twiddle thumbs until we get a signal; allow user to kill */ seteuid(uid); + sigemptyset(&emptyset); while (1) - sigpause(0); + sigsuspend(&emptyset); /* NOTREACHED */ } |