From 18524ce06f298ba424ee03d5d0b8b62a8fad2f23 Mon Sep 17 00:00:00 2001 From: "Alexey I. Froloff" Date: Tue, 14 Aug 2012 17:04:18 +0400 Subject: [PATCH] Better select(2) usage --- wmMatrix/xutils.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/wmMatrix/xutils.c b/wmMatrix/xutils.c index b098cb1..6adb87b 100644 --- a/wmMatrix/xutils.c +++ b/wmMatrix/xutils.c @@ -371,9 +371,12 @@ unsigned long getBlendedColor(char *ColorName, float fac, int red, int grn, int void uusleep(unsigned long usecs) { struct timeval tv; + fd_set fds; tv.tv_sec = usecs / 1000000UL; tv.tv_usec = usecs % 1000000UL; - select(1, NULL, NULL, NULL, &tv); + FD_ZERO(&fds); + FD_SET(x_fd, &fds); + select(x_fd + 1, &fds, NULL, NULL, &tv); } @@ -385,9 +388,12 @@ void uusleep(unsigned long usecs) { void short_uusleep(unsigned long usecs) { struct timeval tv; + fd_set fds; tv.tv_sec = 0; tv.tv_usec = usecs; - select(1, NULL, NULL, NULL, &tv); + FD_ZERO(&fds); + FD_SET(x_fd, &fds); + select(x_fd + 1, &fds, NULL, NULL, &tv); }