Tue Dec 20 21:07:56 2011 UTC ()
thunk_pollchar: use read instead of getchar


(jmcneill)
diff -r1.48 -r1.49 src/sys/arch/usermode/usermode/thunk.c

cvs diff -r1.48 -r1.49 src/sys/arch/usermode/usermode/thunk.c (expand / switch to context diff)
--- src/sys/arch/usermode/usermode/thunk.c 2011/12/20 15:45:37 1.48
+++ src/sys/arch/usermode/usermode/thunk.c 2011/12/20 21:07:56 1.49
@@ -1,4 +1,4 @@
-/* $NetBSD: thunk.c,v 1.48 2011/12/20 15:45:37 reinoud Exp $ */
+/* $NetBSD: thunk.c,v 1.49 2011/12/20 21:07:56 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2011 Jared D. McNeill <jmcneill@invisible.ca>
@@ -28,7 +28,7 @@
 
 #include <sys/cdefs.h>
 #ifdef __NetBSD__
-__RCSID("$NetBSD: thunk.c,v 1.48 2011/12/20 15:45:37 reinoud Exp $");
+__RCSID("$NetBSD: thunk.c,v 1.49 2011/12/20 21:07:56 jmcneill Exp $");
 #endif
 
 #include <sys/types.h>
@@ -381,6 +381,7 @@
 thunk_pollchar(void)
 {
 	struct pollfd fds[1];
+	uint8_t c;
 
 	fds[0].fd = STDIN_FILENO;
 	fds[0].events = POLLIN;
@@ -388,7 +389,9 @@
 
 	if (poll(fds, __arraycount(fds), 0) > 0) {
 		if (fds[0].revents & POLLIN) {
-			return getchar();
+			if (read(STDIN_FILENO, &c, 1) != 1)
+				return EOF;
+			return c;
 		}
 	}