summaryrefslogtreecommitdiffstats
path: root/Source/cmExecuteProcessCommand.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2015-05-07 18:40:38 (GMT)
committerBrad King <brad.king@kitware.com>2015-05-07 18:40:38 (GMT)
commitf65bb82f3688ba33faccf2ef0690571e1aa6edc2 (patch)
tree109fa5d5bcbc524b05f066b15749272f969f5ec8 /Source/cmExecuteProcessCommand.cxx
parent31c218e6e12affd482b9ce2880bd9385c77d9025 (diff)
downloadCMake-f65bb82f3688ba33faccf2ef0690571e1aa6edc2.zip
CMake-f65bb82f3688ba33faccf2ef0690571e1aa6edc2.tar.gz
CMake-f65bb82f3688ba33faccf2ef0690571e1aa6edc2.tar.bz2
execute_process: Improve stdout/stderr merging
Use the KWSys Process "MergeOutput" option to give the child process the same pipe (or file) for both stdout and stderr. This allows natural merging of stdout and stderr together instead of merging on arbitrary buffered read boundaries as before.
Diffstat (limited to 'Source/cmExecuteProcessCommand.cxx')
-rw-r--r--Source/cmExecuteProcessCommand.cxx24
1 files changed, 19 insertions, 5 deletions
diff --git a/Source/cmExecuteProcessCommand.cxx b/Source/cmExecuteProcessCommand.cxx
index 1225992..a371390 100644
--- a/Source/cmExecuteProcessCommand.cxx
+++ b/Source/cmExecuteProcessCommand.cxx
@@ -255,7 +255,7 @@ bool cmExecuteProcessCommand
cmsysProcess_SetOption(cp, cmsysProcess_Option_HideWindow, 1);
// Check the output variables.
- bool merge_output = (output_variable == error_variable);
+ bool merge_output = false;
if(!input_file.empty())
{
cmsysProcess_SetPipeFile(cp, cmsysProcess_Pipe_STDIN, input_file.c_str());
@@ -267,8 +267,23 @@ bool cmExecuteProcessCommand
}
if(!error_file.empty())
{
- cmsysProcess_SetPipeFile(cp, cmsysProcess_Pipe_STDERR,
- error_file.c_str());
+ if (error_file == output_file)
+ {
+ merge_output = true;
+ }
+ else
+ {
+ cmsysProcess_SetPipeFile(cp, cmsysProcess_Pipe_STDERR,
+ error_file.c_str());
+ }
+ }
+ if (!output_variable.empty() && output_variable == error_variable)
+ {
+ merge_output = true;
+ }
+ if (merge_output)
+ {
+ cmsysProcess_SetOption(cp, cmsysProcess_Option_MergeOutput, 1);
}
// Set the timeout if any.
@@ -289,8 +304,7 @@ bool cmExecuteProcessCommand
while((p = cmsysProcess_WaitForData(cp, &data, &length, 0), p))
{
// Put the output in the right place.
- if((p == cmsysProcess_Pipe_STDOUT && !output_quiet) ||
- (p == cmsysProcess_Pipe_STDERR && !error_quiet && merge_output))
+ if (p == cmsysProcess_Pipe_STDOUT && !output_quiet)
{
if(output_variable.empty())
{