From 9374bea84124df5fa6ef91ac4ae0fe3739038b2c Mon Sep 17 00:00:00 2001 From: zolliker Date: Mon, 10 Nov 2008 16:19:22 +0000 Subject: [PATCH] - correct treatment of timeout=NULL --- tecs/uselect.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/tecs/uselect.c b/tecs/uselect.c index 4060270..4173a80 100644 --- a/tecs/uselect.c +++ b/tecs/uselect.c @@ -1,5 +1,6 @@ #include #include +#include #include "uselect.h" /* an uninterruptable version of select. M.Z. Oct 2008 */ @@ -9,10 +10,15 @@ int uselect(int nfds, struct timeval *timeout) { sigset_t sigmask; - struct timespec tmo; - - sigfillset(&sigmask); - tmo.tv_sec = timeout->tv_sec; - tmo.tv_nsec = timeout->tv_usec * 1000; - return pselect(nfds, readfds, writefds, exceptfds, &tmo, &sigmask); + struct timespec tmo, *tmoPtr; + + sigfillset(&sigmask); + if (timeout) { + tmo.tv_sec = timeout->tv_sec; + tmo.tv_nsec = timeout->tv_usec * 1000; + tmoPtr = &tmo; + } else { + tmoPtr = NULL; + } + return pselect(nfds, readfds, writefds, exceptfds, tmoPtr, &sigmask); }