Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/usermode/usermode thunk_pollchar: use read instead ...



details:   https://anonhg.NetBSD.org/src/rev/26eb96f009e3
branches:  trunk
changeset: 772152:26eb96f009e3
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Tue Dec 20 21:07:56 2011 +0000

description:
thunk_pollchar: use read instead of getchar

diffstat:

 sys/arch/usermode/usermode/thunk.c |  9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diffs (37 lines):

diff -r 6881a2e07af7 -r 26eb96f009e3 sys/arch/usermode/usermode/thunk.c
--- a/sys/arch/usermode/usermode/thunk.c        Tue Dec 20 21:01:39 2011 +0000
+++ b/sys/arch/usermode/usermode/thunk.c        Tue Dec 20 21:07:56 2011 +0000
@@ -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@localhost>
@@ -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;
                }
        }
 



Home | Main Index | Thread Index | Old Index