From d118d73fbdc5246b7cddf38088636ffc4977fa48 Mon Sep 17 00:00:00 2001 From: Theo de Raadt Date: Wed, 5 Sep 2001 20:03:08 +0000 Subject: use select() better --- games/boggle/boggle/timer.c | 8 ++++---- games/tetris/input.c | 9 ++++++--- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/games/boggle/boggle/timer.c b/games/boggle/boggle/timer.c index 6d950ece842..c29b7d4e84b 100644 --- a/games/boggle/boggle/timer.c +++ b/games/boggle/boggle/timer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: timer.c,v 1.3 1999/05/26 08:29:10 deraadt Exp $ */ +/* $OpenBSD: timer.c,v 1.4 2001/09/05 20:03:07 deraadt Exp $ */ /* $NetBSD: timer.c,v 1.3 1995/04/24 12:22:45 cgd Exp $ */ /*- @@ -41,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)timer.c 8.2 (Berkeley) 2/22/94"; #else -static char rcsid[] = "$OpenBSD: timer.c,v 1.3 1999/05/26 08:29:10 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: timer.c,v 1.4 2001/09/05 20:03:07 deraadt Exp $"; #endif #endif /* not lint */ @@ -111,7 +111,7 @@ waitch(delay) duration.tv_usec = delay; FD_ZERO(&fdbits); FD_SET(STDIN_FILENO, &fdbits); - return (select(32, &fdbits, NULL, NULL, &duration)); + return (select(STDIN_FILENO+1, &fdbits, NULL, NULL, &duration)); } void @@ -122,5 +122,5 @@ delay(tenths) duration.tv_usec = (tenths % 10 ) * 100000L; duration.tv_sec = (long) (tenths / 10); - select(32, 0, 0, 0, &duration); + select(0, 0, 0, 0, &duration); } diff --git a/games/tetris/input.c b/games/tetris/input.c index d2cdc003b0b..dd16dab90bd 100644 --- a/games/tetris/input.c +++ b/games/tetris/input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: input.c,v 1.5 2001/02/04 14:23:27 pjanzen Exp $ */ +/* $OpenBSD: input.c,v 1.6 2001/09/05 20:03:07 deraadt Exp $ */ /* $NetBSD: input.c,v 1.3 1996/02/06 22:47:33 jtc Exp $ */ /*- @@ -81,6 +81,8 @@ rwait(tvp) { int i; struct timeval starttv, endtv, *s; + fd_set fds; + #define NILTZ ((struct timezone *)0) /* @@ -95,8 +97,9 @@ rwait(tvp) } else s = NULL; again: - i = 1; - switch (select(1, (fd_set *)&i, (fd_set *)0, (fd_set *)0, s)) { + FD_ZERO(&fds); + FD_SET(STDIN_FILENO, &fds); + switch (select(STDIN_FILENO + 1, &fds, (fd_set *)0, (fd_set *)0, s)) { case -1: if (tvp == 0) -- cgit v1.2.3