diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2008-03-26 20:13:00 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2008-03-26 20:13:00 +0000 |
commit | a11f0f1cc2d22bb0a320c203d40ce47bf5f8d9ec (patch) | |
tree | b5082e88fcb70d5fb115123545f0ad0f0cf39f72 | |
parent | 9ac2f54bcf1b2e60384d4a71e415e2a20c681f8d (diff) |
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@
-rw-r--r-- | games/boggle/boggle/mach.c | 12 | ||||
-rw-r--r-- | games/boggle/boggle/timer.c | 6 |
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()); } /* |