From 35283aa36d01244db79e1b51e36b0dd56a4fb515 Mon Sep 17 00:00:00 2001 From: insofaras Date: Thu, 16 Jun 2016 23:50:45 +0100 Subject: [PATCH] linux: fix infinite loop bug --- linux_4ed.cpp | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/linux_4ed.cpp b/linux_4ed.cpp index 52144ef3..815c1270 100644 --- a/linux_4ed.cpp +++ b/linux_4ed.cpp @@ -2795,23 +2795,19 @@ main(int argc, char **argv) case LINUX_4ED_EVENT_STEP: { u64 ev; - while(read(linuxvars.step_event_fd, &ev, 8) == -1){ - if(errno != EINTR && errno != EAGAIN){ - perror("eventfd read"); - break; - } - } + int ret; + do { + ret = read(linuxvars.step_event_fd, &ev, 8); + } while(ret != -1 || errno != EAGAIN); do_step = 1; } break; case LINUX_4ED_EVENT_STEP_TIMER: { u64 count; - while(read(linuxvars.step_timer_fd, &count, 8) == -1){ - if(errno != EINTR && errno != EAGAIN){ - perror("timerfd read"); - break; - } - } + int ret; + do { + ret = read(linuxvars.step_timer_fd, &count, 8); + } while(ret != -1 || errno != EAGAIN); do_step = 1; } break;