diff -ru cmake-2.6.4.orig/Source/kwsys/ProcessUNIX.c cmake-2.6.4/Source/kwsys/ProcessUNIX.c --- cmake-2.6.4.orig/Source/kwsys/ProcessUNIX.c 2010-02-17 14:39:20 +0100 +++ cmake-2.6.4/Source/kwsys/ProcessUNIX.c 2010-02-17 15:52:30 +0100 @@ -1018,6 +1018,9 @@ int numReady = 0; int max = -1; kwsysProcessTimeNative* timeout = 0; +#ifdef __INTERIX + int is_sig_only = 0; +#endif /* Check for any open pipes with data reported ready by the last call to select. According to "man select_tut" we must deal @@ -1125,9 +1128,65 @@ /* Run select to block until data are available. Repeat call until it is not interrupted. */ +#ifdef __INTERIX + /* hack around broken sh** ... */ + is_sig_only = 1; + for(i=0; i < KWSYSPE_PIPE_COUNT; ++i) { + if(cp->PipeReadEnds[i] >= 0) { + if(i != KWSYSPE_PIPE_SIGNAL) + is_sig_only = 0; + } else { + if(i == KWSYSPE_PIPE_SIGNAL) + is_sig_only = 0; + } + } + + if(is_sig_only && !timeout) { + static kwsysProcessTimeNative _tmp = { 1,0 }; + timeout = &_tmp; + } + + while(1) { +#endif + while(((numReady = select(max+1, &cp->PipeSet, 0, 0, timeout)) < 0) && (errno == EINTR)); +#ifdef __INTERIX + if(!is_sig_only) + break; + + if(numReady != 0) + break; + + /* only signal pipe left over, and nothing waiting ... + * we'll just wait() for the process to see whether it still exists. + * if it does, we continue to select, otherwise we return 0. no need + * to modify the PipeSet as the pipe will be set in there anyway then. */ + for(i=0; i < cp->NumberOfCommands; ++i) + { + if(cp->ForkPIDs[i]) + { + int result; + while(((result = waitpid(cp->ForkPIDs[i], + &cp->CommandExitCodes[i], WNOHANG)) < 0) && + (errno == EINTR)); + if(result == cp->ForkPIDs[i]) + { + /* uh ... process terminated, SIGCHLD got lost? + * what should i DO here? */ + + /* Set the pipe in a signalled state. */ + kwsysProcessCleanupDescriptor(&cp->SignalPipe); + return 1; + } + } + } + /* no process terminated, nothing select()ed. */ + continue; + } +#endif + /* Check result of select. */ if(numReady == 0) { @@ -1215,12 +1274,16 @@ return 1; } +/* errr.... this looks wrong, and is not done for the select() part above. + * (the kwsysProcessGetTimeoutLeft part from above is in both code paths). */ +#if 0 if((timeoutLength.tv_sec == 0) && (timeoutLength.tv_usec == 0)) { /* Timeout has already expired. */ wd->Expired = 1; return 1; } +#endif /* Sleep a little, try again. */ {