diff options
Diffstat (limited to 'usr.bin/tip/tip/tipout.c')
-rw-r--r-- | usr.bin/tip/tip/tipout.c | 58 |
1 files changed, 28 insertions, 30 deletions
diff --git a/usr.bin/tip/tip/tipout.c b/usr.bin/tip/tip/tipout.c index ac40ec7d0bd2..e8e380e400bb 100644 --- a/usr.bin/tip/tip/tipout.c +++ b/usr.bin/tip/tip/tipout.c @@ -1,3 +1,6 @@ +/* $OpenBSD: tipout.c,v 1.8 2001/10/24 18:38:58 millert Exp $ */ +/* $NetBSD: tipout.c,v 1.5 1996/12/29 10:34:12 cgd Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -31,17 +34,17 @@ * SUCH DAMAGE. */ +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + #ifndef lint #if 0 static char sccsid[] = "@(#)tipout.c 8.1 (Berkeley) 6/6/93"; +static char rcsid[] = "$OpenBSD: tipout.c,v 1.8 2001/10/24 18:38:58 millert Exp $"; #endif -static const char rcsid[] = - "$FreeBSD$"; #endif /* not lint */ #include "tip.h" -#include <errno.h> -#include <unistd.h> /* * tip * @@ -72,7 +75,7 @@ void intEMT() { char c, line[256]; - register char *pline = line; + char *pline = line; char reply; read(fildes[0], &c, 1); @@ -84,14 +87,14 @@ intEMT() if (boolean(value(SCRIPT)) && fscript != NULL) fclose(fscript); if (pline == line) { - boolean(value(SCRIPT)) = FALSE; + setboolean(value(SCRIPT), FALSE); reply = 'y'; } else { if ((fscript = fopen(line, "a")) == NULL) reply = 'n'; else { reply = 'y'; - boolean(value(SCRIPT)) = TRUE; + setboolean(value(SCRIPT), TRUE); } } write(repdes[1], &reply, 1); @@ -111,7 +114,7 @@ void intSYS() { - boolean(value(BEAUTIFY)) = !boolean(value(BEAUTIFY)); + setboolean(value(BEAUTIFY), !boolean(value(BEAUTIFY))); longjmp(sigbuf, 1); } @@ -122,9 +125,9 @@ void tipout() { char buf[BUFSIZ]; - register char *cp; - register int cnt; - int omask; + char *cp; + int cnt; + sigset_t mask, omask; signal(SIGINT, SIG_IGN); signal(SIGQUIT, SIG_IGN); @@ -134,35 +137,30 @@ 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)); - intTERM(); - /*NOTREACHED*/ - } else if (cnt == 0 && errno == ENOENT) { - if (getppid() != 1) - kill(getppid(),SIGUSR1); - sigblock(sigmask(SIGTERM)); - intTERM(); - /*NOTREACHED*/ - } else if (cnt < 0) { - if (getppid() != 1) - kill(getppid(),SIGUSR1); - 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 &= 0177; - if (write(STDOUT_FILENO, buf, cnt) < 0) - exit(1); + *cp &= STRIP_PAR; + write(1, buf, cnt); if (boolean(value(SCRIPT)) && fscript != NULL) { if (!boolean(value(BEAUTIFY))) { fwrite(buf, 1, cnt, fscript); |