summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>2003-10-15 22:33:18 +0000
committerderaadt <deraadt@openbsd.org>2003-10-15 22:33:18 +0000
commitd9533048659f387ddc907984361c4ee322e3730a (patch)
treea39462e2f610b23653ce7966d9dad2e4009580a6
parentabort on errors by default. workaround so running out of memory isn't (diff)
downloadwireguard-openbsd-d9533048659f387ddc907984361c4ee322e3730a.tar.xz
wireguard-openbsd-d9533048659f387ddc907984361c4ee322e3730a.zip
on fatal error, repair tty; millert ok
-rw-r--r--usr.bin/tip/tip.c9
-rw-r--r--usr.bin/tip/tip.h3
2 files changed, 8 insertions, 4 deletions
diff --git a/usr.bin/tip/tip.c b/usr.bin/tip/tip.c
index b7b16439479..3e862851d7e 100644
--- a/usr.bin/tip/tip.c
+++ b/usr.bin/tip/tip.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tip.c,v 1.21 2003/09/20 18:15:32 millert Exp $ */
+/* $OpenBSD: tip.c,v 1.22 2003/10/15 22:33:18 deraadt Exp $ */
/* $NetBSD: tip.c,v 1.13 1997/04/20 00:03:05 mellon Exp $ */
/*
@@ -40,7 +40,7 @@ static const char copyright[] =
#if 0
static char sccsid[] = "@(#)tip.c 8.1 (Berkeley) 6/6/93";
#endif
-static const char rcsid[] = "$OpenBSD: tip.c,v 1.21 2003/09/20 18:15:32 millert Exp $";
+static const char rcsid[] = "$OpenBSD: tip.c,v 1.22 2003/10/15 22:33:18 deraadt Exp $";
#endif /* not lint */
/*
@@ -212,6 +212,7 @@ cucommon:
}
tcgetattr(0, &defterm);
+ gotdefterm = 1;
term = defterm;
term.c_lflag &= ~(ICANON|IEXTEN|ECHO);
term.c_iflag &= ~(INPCK|ICRNL);
@@ -251,6 +252,7 @@ cleanup()
(void)uu_unlock(uucplock);
if (odisc)
ioctl(0, TIOCSETD, (char *)&odisc);
+ unraw();
exit(0);
}
@@ -306,7 +308,8 @@ raw()
void
unraw()
{
- tcsetattr(0, TCSADRAIN, &defterm);
+ if (gotdefterm)
+ tcsetattr(0, TCSADRAIN, &defterm);
}
static jmp_buf promptbuf;
diff --git a/usr.bin/tip/tip.h b/usr.bin/tip/tip.h
index 3540f144eb7..c976ab20492 100644
--- a/usr.bin/tip/tip.h
+++ b/usr.bin/tip/tip.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tip.h,v 1.16 2003/09/20 18:15:32 millert Exp $ */
+/* $OpenBSD: tip.h,v 1.17 2003/10/15 22:33:18 deraadt Exp $ */
/* $NetBSD: tip.h,v 1.7 1997/04/20 00:02:46 mellon Exp $ */
/*
@@ -234,6 +234,7 @@ extern value_t vtable[]; /* variable table */
struct termios term; /* current mode of terminal */
struct termios defterm; /* initial mode of terminal */
struct termios defchars; /* current mode with initial chars */
+int gotdefterm;
FILE *fscript; /* FILE for scripting */