diff options
author | Brad King <brad.king@kitware.com> | 2009-06-10 15:46:21 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2009-06-10 15:46:21 (GMT) |
commit | 1eec4fe6ad8021343f910aff0faab65548526bbc (patch) | |
tree | 3f7416cad252fdc5a00e4f20ff156e1f85f2b1fc /Source/kwsys/ProcessUNIX.c | |
parent | 776e21d1c7a3414aff8d307aaaef56abd907d8d5 (diff) | |
download | CMake-1eec4fe6ad8021343f910aff0faab65548526bbc.zip CMake-1eec4fe6ad8021343f910aff0faab65548526bbc.tar.gz CMake-1eec4fe6ad8021343f910aff0faab65548526bbc.tar.bz2 |
BUG: Fix non-select process impl without timeout
This avoids use of an uninitialized value in the KWSys ProcessUNIX
polling implementation when no timeout is given.
Diffstat (limited to 'Source/kwsys/ProcessUNIX.c')
-rw-r--r-- | Source/kwsys/ProcessUNIX.c | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/Source/kwsys/ProcessUNIX.c b/Source/kwsys/ProcessUNIX.c index a7515ba..d4d7fa1 100644 --- a/Source/kwsys/ProcessUNIX.c +++ b/Source/kwsys/ProcessUNIX.c @@ -156,7 +156,8 @@ static int kwsysProcessGetTimeoutTime(kwsysProcess* cp, double* userTimeout, kwsysProcessTime* timeoutTime); static int kwsysProcessGetTimeoutLeft(kwsysProcessTime* timeoutTime, double* userTimeout, - kwsysProcessTimeNative* timeoutLength); + kwsysProcessTimeNative* timeoutLength, + int zeroIsExpired); static kwsysProcessTime kwsysProcessTimeGetCurrent(void); static double kwsysProcessTimeToDouble(kwsysProcessTime t); static kwsysProcessTime kwsysProcessTimeFromDouble(double d); @@ -1097,7 +1098,7 @@ static int kwsysProcessWaitForPipe(kwsysProcess* cp, char** data, int* length, } if(kwsysProcessGetTimeoutLeft(&wd->TimeoutTime, wd->User?wd->UserTimeout:0, - &timeoutLength)) + &timeoutLength, 0)) { /* Timeout has already expired. */ wd->Expired = 1; @@ -1210,14 +1211,7 @@ static int kwsysProcessWaitForPipe(kwsysProcess* cp, char** data, int* length, } if(kwsysProcessGetTimeoutLeft(&wd->TimeoutTime, wd->User?wd->UserTimeout:0, - &timeoutLength)) - { - /* Timeout has already expired. */ - wd->Expired = 1; - return 1; - } - - if((timeoutLength.tv_sec == 0) && (timeoutLength.tv_usec == 0)) + &timeoutLength, 1)) { /* Timeout has already expired. */ wd->Expired = 1; @@ -1905,7 +1899,8 @@ static int kwsysProcessGetTimeoutTime(kwsysProcess* cp, double* userTimeout, Returns 1 if the time has already arrived, and 0 otherwise. */ static int kwsysProcessGetTimeoutLeft(kwsysProcessTime* timeoutTime, double* userTimeout, - kwsysProcessTimeNative* timeoutLength) + kwsysProcessTimeNative* timeoutLength, + int zeroIsExpired) { if(timeoutTime->tv_sec < 0) { @@ -1925,7 +1920,8 @@ static int kwsysProcessGetTimeoutLeft(kwsysProcessTime* timeoutTime, timeLeft.tv_usec = 0; } - if(timeLeft.tv_sec < 0) + if(timeLeft.tv_sec < 0 || + (timeLeft.tv_sec == 0 && timeLeft.tv_usec == 0 && zeroIsExpired)) { /* Timeout has already expired. */ return 1; |