summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2013-04-20 17:39:51 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2013-04-20 17:39:51 +0000
commit1cc7c5e32a65783f03aed3ec28f0d9d170c075d2 (patch)
treea219c04009855a8f9dcd94b0c472f147d61f207a /usr.bin
parenta0a8d5f2e7371d2bd388fa6ae71cd31ecfade412 (diff)
use poll() instead of select() [with a fixed size fd_set]
ok florian
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/mg/ttyio.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/usr.bin/mg/ttyio.c b/usr.bin/mg/ttyio.c
index 5ce855a0cc1..7f94db52235 100644
--- a/usr.bin/mg/ttyio.c
+++ b/usr.bin/mg/ttyio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ttyio.c,v 1.33 2013/01/19 21:22:28 florian Exp $ */
+/* $OpenBSD: ttyio.c,v 1.34 2013/04/20 17:39:50 deraadt Exp $ */
/* This file is in the public domain. */
@@ -15,6 +15,7 @@
#include <sys/time.h>
#include <sys/ioctl.h>
#include <fcntl.h>
+#include <poll.h>
#include <termios.h>
#include <term.h>
@@ -218,16 +219,12 @@ panic(char *s)
int
ttwait(int msec)
{
- fd_set readfds;
- struct timeval tmout;
+ struct pollfd pfd[1];
- FD_ZERO(&readfds);
- FD_SET(0, &readfds);
+ pfd[0].fd = 0;
+ pfd[0].events = POLLIN;
- tmout.tv_sec = msec/1000;
- tmout.tv_usec = msec - tmout.tv_sec * 1000;
-
- if ((select(1, &readfds, NULL, NULL, &tmout)) == 0)
+ if ((poll(pfd, 1, msec)) == 0)
return (TRUE);
return (FALSE);
}