summaryrefslogtreecommitdiff
path: root/usr.bin/tip
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/tip')
-rw-r--r--usr.bin/tip/aculib/courier.c47
-rw-r--r--usr.bin/tip/aculib/t3000.c47
-rw-r--r--usr.bin/tip/tipout.c22
3 files changed, 30 insertions, 86 deletions
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);