diff options
-rw-r--r-- | Source/kwsys/Process.h.in | 11 | ||||
-rw-r--r-- | Source/kwsys/ProcessUNIX.c | 14 | ||||
-rw-r--r-- | Source/kwsys/ProcessWin32.c | 16 |
3 files changed, 28 insertions, 13 deletions
diff --git a/Source/kwsys/Process.h.in b/Source/kwsys/Process.h.in index 0583c0c..adca44b 100644 --- a/Source/kwsys/Process.h.in +++ b/Source/kwsys/Process.h.in @@ -60,6 +60,7 @@ #define kwsysProcess_Execute kwsys(Process_Execute) #define kwsysProcess_WaitForData kwsys(Process_WaitForData) #define kwsysProcess_Pipes_e kwsys(Process_Pipes_e) +#define kwsysProcess_Pipe_None kwsys(Process_Pipe_None) #define kwsysProcess_Pipe_STDOUT kwsys(Process_Pipe_STDOUT) #define kwsysProcess_Pipe_STDERR kwsys(Process_Pipe_STDERR) #define kwsysProcess_Pipe_Timeout kwsys(Process_Pipe_Timeout) @@ -228,8 +229,8 @@ kwsysEXPORT void kwsysProcess_Execute(kwsysProcess* cp); * * Return value will be one of: * - * 0 = No more data will be available from the child process, - * or no process has been executed. WaitForExit should + * Pipe_None = No more data will be available from the child process, + * ( == 0) or no process has been executed. WaitForExit should * be called to wait for the process to terminate. * Pipe_STDOUT = Data have been read from the child's stdout pipe. * Pipe_STDERR = Data have been read from the child's stderr pipe. @@ -241,8 +242,9 @@ kwsysEXPORT int kwsysProcess_WaitForData(kwsysProcess* cp, char** data, int* length, double* timeout); enum kwsysProcess_Pipes_e { - kwsysProcess_Pipe_STDOUT=1, - kwsysProcess_Pipe_STDERR=2, + kwsysProcess_Pipe_None, + kwsysProcess_Pipe_STDOUT, + kwsysProcess_Pipe_STDERR, kwsysProcess_Pipe_Timeout=255 }; @@ -317,6 +319,7 @@ kwsysEXPORT void kwsysProcess_Kill(kwsysProcess* cp); # undef kwsysProcess_Execute # undef kwsysProcess_WaitForData # undef kwsysProcess_Pipes_e +# undef kwsysProcess_Pipe_None # undef kwsysProcess_Pipe_STDOUT # undef kwsysProcess_Pipe_STDERR # undef kwsysProcess_Pipe_Timeout diff --git a/Source/kwsys/ProcessUNIX.c b/Source/kwsys/ProcessUNIX.c index 7e8c617..cf0fb73 100644 --- a/Source/kwsys/ProcessUNIX.c +++ b/Source/kwsys/ProcessUNIX.c @@ -497,7 +497,7 @@ int kwsysProcess_WaitForData(kwsysProcess* cp, char** data, int* length, kwsysProcessTime userStartTime; int user = 0; int expired = 0; - int pipeId = 0; + int pipeId = kwsysProcess_Pipe_None; int numReady = 0; /* Record the time at which user timeout period starts. */ @@ -542,7 +542,13 @@ int kwsysProcess_WaitForData(kwsysProcess* cp, char** data, int* length, /* Report this data. */ *data = cp->PipeBuffer; *length = n; - pipeId = (1 << i); + switch(i) + { + case KWSYSPE_PIPE_STDOUT: + pipeId = kwsysProcess_Pipe_STDOUT; break; + case KWSYSPE_PIPE_STDERR: + pipeId = kwsysProcess_Pipe_STDERR; break; + }; break; } } @@ -663,13 +669,13 @@ int kwsysProcess_WaitForData(kwsysProcess* cp, char** data, int* length, cp->Killed = 0; cp->TimeoutExpired = 1; cp->PipesLeft = 0; - return 0; + return kwsysProcess_Pipe_None; } } else { /* No pipes are left open. */ - return 0; + return kwsysProcess_Pipe_None; } } diff --git a/Source/kwsys/ProcessWin32.c b/Source/kwsys/ProcessWin32.c index fd4ddd0..07a7855 100644 --- a/Source/kwsys/ProcessWin32.c +++ b/Source/kwsys/ProcessWin32.c @@ -931,14 +931,14 @@ int kwsysProcess_WaitForData(kwsysProcess* cp, char** data, int* length, int user; int done = 0; int expired = 0; - int pipeId = 0; + int pipeId = kwsysProcess_Pipe_None; DWORD w; /* Make sure we are executing a process. */ if(cp->State != kwsysProcess_State_Executing || cp->Killed || cp->TimeoutExpired) { - return 0; + return kwsysProcess_Pipe_None; } /* Record the time at which user timeout period starts. */ @@ -1002,7 +1002,13 @@ int kwsysProcess_WaitForData(kwsysProcess* cp, char** data, int* length, /* Report this data. */ *data = cp->Pipe[cp->CurrentIndex].DataBuffer; *length = cp->Pipe[cp->CurrentIndex].DataLength; - pipeId = (1 << cp->CurrentIndex); + switch(cp->CurrentIndex) + { + case KWSYSPE_PIPE_STDOUT: + pipeId = kwsysProcess_Pipe_STDOUT; break; + case KWSYSPE_PIPE_STDERR: + pipeId = kwsysProcess_Pipe_STDERR; break; + } done = 1; } } @@ -1047,13 +1053,13 @@ int kwsysProcess_WaitForData(kwsysProcess* cp, char** data, int* length, kwsysProcess_Kill(cp); cp->TimeoutExpired = 1; cp->Killed = 0; - return 0; + return kwsysProcess_Pipe_None; } } else { /* The children have terminated and no more data are available. */ - return 0; + return kwsysProcess_Pipe_None; } } |