summaryrefslogtreecommitdiffstats
path: root/games/boggle
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>2008-03-26 20:12:59 +0000
committermillert <millert@openbsd.org>2008-03-26 20:12:59 +0000
commit5967f7bbdb6df3bd1e95a7295c75b8ef35307154 (patch)
tree239108bf9d944bb33bdbbdbf21f73461bf2c1eea /games/boggle
parentsync (diff)
downloadwireguard-openbsd-5967f7bbdb6df3bd1e95a7295c75b8ef35307154.tar.xz
wireguard-openbsd-5967f7bbdb6df3bd1e95a7295c75b8ef35307154.zip
Bomb out if we cannot read the input. This happens when select
says there has been a status change to indicate that the tty has gone away. Prevents spinning on terminal detach. OK pvalchev@
Diffstat (limited to 'games/boggle')
-rw-r--r--games/boggle/boggle/mach.c12
-rw-r--r--games/boggle/boggle/timer.c6
2 files changed, 11 insertions, 7 deletions
diff --git a/games/boggle/boggle/mach.c b/games/boggle/boggle/mach.c
index 29540db96e0..ebde78434d5 100644
--- a/games/boggle/boggle/mach.c
+++ b/games/boggle/boggle/mach.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mach.c,v 1.9 2008/03/20 12:02:27 millert Exp $ */
+/* $OpenBSD: mach.c,v 1.10 2008/03/26 20:12:59 millert Exp $ */
/* $NetBSD: mach.c,v 1.5 1995/04/28 22:28:48 mycroft Exp $ */
/*-
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)mach.c 8.1 (Berkeley) 6/11/93";
#else
-static char rcsid[] = "$OpenBSD: mach.c,v 1.9 2008/03/20 12:02:27 millert Exp $";
+static char rcsid[] = "$OpenBSD: mach.c,v 1.10 2008/03/26 20:12:59 millert Exp $";
#endif
#endif /* not lint */
@@ -298,7 +298,11 @@ getline(char *q)
int
inputch(void)
{
- return (getch() & 0177);
+ int ch;
+
+ if ((ch = getch()) == ERR)
+ err(1, "cannot read input");
+ return (ch & 0177);
}
void
@@ -538,7 +542,7 @@ getword(char *q)
addch('[');
refresh();
while (!done && i < MAXWORDLEN - 1) {
- ch = getch() & 0177;
+ ch = inputch();
switch (ch) {
case '\177': /* <del> */
case '\010': /* <bs> */
diff --git a/games/boggle/boggle/timer.c b/games/boggle/boggle/timer.c
index 6b088d55bfd..aebb4f2b9c1 100644
--- a/games/boggle/boggle/timer.c
+++ b/games/boggle/boggle/timer.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: timer.c,v 1.8 2008/03/20 12:02:27 millert Exp $ */
+/* $OpenBSD: timer.c,v 1.9 2008/03/26 20:12:59 millert Exp $ */
/* $NetBSD: timer.c,v 1.3 1995/04/24 12:22:45 cgd Exp $ */
/*-
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)timer.c 8.2 (Berkeley) 2/22/94";
#else
-static char rcsid[] = "$OpenBSD: timer.c,v 1.8 2008/03/20 12:02:27 millert Exp $";
+static char rcsid[] = "$OpenBSD: timer.c,v 1.9 2008/03/26 20:12:59 millert Exp $";
#endif
#endif /* not lint */
@@ -91,7 +91,7 @@ timerch(void)
move(row, col);
refresh();
}
- return (getch() & 0177);
+ return (inputch());
}
/*