ENH: Removed pipe selection argument from WaitForData method in kwsysProcess. This greatly simplifies its use.
This commit is contained in:
parent
97b469537b
commit
ed853b5d70
|
@ -2363,9 +2363,7 @@ int cmCTest::RunMakeCommand(const char* command, std::string* output,
|
|||
std::cout << " Each . represents " << tick_len << " bytes of output" << std::endl;
|
||||
std::cout << " " << std::flush;
|
||||
}
|
||||
while(cmsysProcess_WaitForData(cp, (cmsysProcess_Pipe_STDOUT |
|
||||
cmsysProcess_Pipe_STDERR),
|
||||
&data, &length, 0))
|
||||
while(cmsysProcess_WaitForData(cp, &data, &length, 0))
|
||||
{
|
||||
if ( output )
|
||||
{
|
||||
|
@ -2454,9 +2452,7 @@ int cmCTest::RunTest(std::vector<const char*> argv, std::string* output, int *re
|
|||
|
||||
char* data;
|
||||
int length;
|
||||
while(cmsysProcess_WaitForData(cp, (cmsysProcess_Pipe_STDOUT |
|
||||
cmsysProcess_Pipe_STDERR),
|
||||
&data, &length, 0))
|
||||
while(cmsysProcess_WaitForData(cp, &data, &length, 0))
|
||||
{
|
||||
if ( output )
|
||||
{
|
||||
|
|
|
@ -403,9 +403,7 @@ bool cmSystemTools::RunSingleCommand(
|
|||
std::vector<char> tempOutput;
|
||||
char* data;
|
||||
int length;
|
||||
while(cmsysProcess_WaitForData(cp, (cmsysProcess_Pipe_STDOUT |
|
||||
cmsysProcess_Pipe_STDERR),
|
||||
&data, &length, 0))
|
||||
while(cmsysProcess_WaitForData(cp, &data, &length, 0))
|
||||
{
|
||||
if ( output )
|
||||
{
|
||||
|
|
|
@ -213,13 +213,9 @@ kwsysEXPORT const char* kwsysProcess_GetErrorString(kwsysProcess* cp);
|
|||
kwsysEXPORT void kwsysProcess_Execute(kwsysProcess* cp);
|
||||
|
||||
/**
|
||||
* Block until data are available on a requested pipe, a timeout
|
||||
* expires, or the child process terminates. Arguments are as
|
||||
* follows:
|
||||
* Block until data are available on a pipe, a timeout expires, or the
|
||||
* child process terminates. Arguments are as follows:
|
||||
*
|
||||
* pipes = Flags for the child output pipes of interest to the caller.
|
||||
* Possible values are Pipe_STDOUT and Pipe_STDERR. Multiple
|
||||
* pipes may be specified by using the bitwise OR operator '|'.
|
||||
* data = If data are read, the pointer to which this points is
|
||||
* set to point to the data.
|
||||
* length = If data are read, the integer to which this points is
|
||||
|
@ -241,9 +237,8 @@ kwsysEXPORT void kwsysProcess_Execute(kwsysProcess* cp);
|
|||
* call. Time elapsed has been subtracted from timeout
|
||||
* argument.
|
||||
*/
|
||||
kwsysEXPORT int kwsysProcess_WaitForData(kwsysProcess* cp, int pipes,
|
||||
char** data, int* length,
|
||||
double* timeout);
|
||||
kwsysEXPORT int kwsysProcess_WaitForData(kwsysProcess* cp, char** data,
|
||||
int* length, double* timeout);
|
||||
enum kwsysProcess_Pipes_e
|
||||
{
|
||||
kwsysProcess_Pipe_STDOUT=1,
|
||||
|
|
|
@ -486,8 +486,8 @@ void kwsysProcess_Execute(kwsysProcess* cp)
|
|||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
int kwsysProcess_WaitForData(kwsysProcess* cp, int pipes, char** data,
|
||||
int* length, double* userTimeout)
|
||||
int kwsysProcess_WaitForData(kwsysProcess* cp, char** data, int* length,
|
||||
double* userTimeout)
|
||||
{
|
||||
int i;
|
||||
int max = -1;
|
||||
|
@ -537,9 +537,9 @@ int kwsysProcess_WaitForData(kwsysProcess* cp, int pipes, char** data,
|
|||
{
|
||||
/* This is data on the special termination pipe. Ignore it. */
|
||||
}
|
||||
else if(pipes & (1 << i))
|
||||
else if(data && length)
|
||||
{
|
||||
/* Caller wants this data. Report it. */
|
||||
/* Report this data. */
|
||||
*data = cp->PipeBuffer;
|
||||
*length = n;
|
||||
pipeId = (1 << i);
|
||||
|
@ -687,7 +687,7 @@ int kwsysProcess_WaitForExit(kwsysProcess* cp, double* userTimeout)
|
|||
}
|
||||
|
||||
/* Wait for all the pipes to close. Ignore all data. */
|
||||
while((pipe = kwsysProcess_WaitForData(cp, 0, 0, 0, userTimeout)) > 0)
|
||||
while((pipe = kwsysProcess_WaitForData(cp, 0, 0, userTimeout)) > 0)
|
||||
{
|
||||
if(pipe == kwsysProcess_Pipe_Timeout)
|
||||
{
|
||||
|
|
|
@ -921,7 +921,7 @@ void kwsysProcess_Execute(kwsysProcess* cp)
|
|||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
int kwsysProcess_WaitForData(kwsysProcess* cp, int pipes, char** data, int* length,
|
||||
int kwsysProcess_WaitForData(kwsysProcess* cp, char** data, int* length,
|
||||
double* userTimeout)
|
||||
{
|
||||
kwsysProcessTime userStartTime;
|
||||
|
@ -997,18 +997,14 @@ int kwsysProcess_WaitForData(kwsysProcess* cp, int pipes, char** data, int* leng
|
|||
/* The pipe closed. */
|
||||
--cp->PipesLeft;
|
||||
}
|
||||
else if(pipes & (1 << cp->CurrentIndex))
|
||||
else if(data && length)
|
||||
{
|
||||
/* Caller wants this data. Report it. */
|
||||
/* Report this data. */
|
||||
*data = cp->Pipe[cp->CurrentIndex].DataBuffer;
|
||||
*length = cp->Pipe[cp->CurrentIndex].DataLength;
|
||||
pipeId = (1 << cp->CurrentIndex);
|
||||
done = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Caller does not care about this pipe. Ignore the data. */
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1074,7 +1070,7 @@ int kwsysProcess_WaitForExit(kwsysProcess* cp, double* userTimeout)
|
|||
}
|
||||
|
||||
/* Wait for the process to terminate. Ignore all data. */
|
||||
while((pipe = kwsysProcess_WaitForData(cp, 0, 0, 0, userTimeout)) > 0)
|
||||
while((pipe = kwsysProcess_WaitForData(cp, 0, 0, userTimeout)) > 0)
|
||||
{
|
||||
if(pipe == kwsysProcess_Pipe_Timeout)
|
||||
{
|
||||
|
|
|
@ -11,9 +11,7 @@ int main()
|
|||
kwsysProcess_Execute(kp);
|
||||
char* data = 0;
|
||||
int length = 0;
|
||||
while(kwsysProcess_WaitForData(kp, (kwsysProcess_Pipe_STDOUT |
|
||||
kwsysProcess_Pipe_STDERR),
|
||||
&data, &length, 0))
|
||||
while(kwsysProcess_WaitForData(kp, &data, &length, 0))
|
||||
{
|
||||
kwsys_std::cout.write(data, length);
|
||||
}
|
||||
|
|
|
@ -66,9 +66,7 @@ int runChild(const char* cmd[], int state, int exception, int value)
|
|||
kwsysProcess_SetTimeout(kp, 3);
|
||||
kwsysProcess_Execute(kp);
|
||||
|
||||
while(kwsysProcess_WaitForData(kp, (kwsysProcess_Pipe_STDOUT |
|
||||
kwsysProcess_Pipe_STDERR),
|
||||
&data, &length, 0))
|
||||
while(kwsysProcess_WaitForData(kp, &data, &length, 0))
|
||||
{
|
||||
fwrite(data, 1, length, stdout);
|
||||
fflush(stdout);
|
||||
|
|
Loading…
Reference in New Issue