From 8eb47d298631e727f9747e56faa14a40234b2d22 Mon Sep 17 00:00:00 2001 From: Sasha Levin Date: Wed, 6 Apr 2011 21:47:27 +0300 Subject: [PATCH] kvm tools: Fix input hang when compiling without optimization When compiling without optimizations (-O0) input would hang. This was caused by poll() returning there was data to read but read() failing. Signed-off-by: Sasha Levin Signed-off-by: Pekka Enberg --- 8250-serial.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/8250-serial.c b/8250-serial.c index f0aa69e..939e9f5 100644 --- a/8250-serial.c +++ b/8250-serial.c @@ -1,5 +1,6 @@ #include "kvm/8250-serial.h" +#include "kvm/read-write.h" #include "kvm/ioport.h" #include "kvm/util.h" #include "kvm/kvm.h" @@ -55,9 +56,9 @@ static struct serial8250_device devices[] = { static int read_char(int fd) { - int c; + char c; - if (read(fd, &c, 1) < 0) + if (read_in_full(fd, &c, 1) == 0) return -1; return c;