diff options
author | Zach Mullen <zach.mullen@kitware.com> | 2009-09-08 14:16:16 (GMT) |
---|---|---|
committer | Zach Mullen <zach.mullen@kitware.com> | 2009-09-08 14:16:16 (GMT) |
commit | a02ef564018be7e383992d52399279ea7cf48c91 (patch) | |
tree | 72261a3b4befbf6a644c3c3216f83420a9c634ba /Source/CTest/cmProcess.cxx | |
parent | 384f4d1f3f14e57a56a43b4f99233c9210041846 (diff) | |
download | CMake-a02ef564018be7e383992d52399279ea7cf48c91.zip CMake-a02ef564018be7e383992d52399279ea7cf48c91.tar.gz CMake-a02ef564018be7e383992d52399279ea7cf48c91.tar.bz2 |
BUG: Fixed issue where ctest would hang if a process terminated with output in its buffers but no newline
Diffstat (limited to 'Source/CTest/cmProcess.cxx')
-rw-r--r-- | Source/CTest/cmProcess.cxx | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/Source/CTest/cmProcess.cxx b/Source/CTest/cmProcess.cxx index ed1c531..458c77a 100644 --- a/Source/CTest/cmProcess.cxx +++ b/Source/CTest/cmProcess.cxx @@ -77,7 +77,8 @@ bool cmProcess::StartProcess() int cmProcess::GetNextOutputLine(std::string& stdOutLine, std::string& stdErrLine, bool& gotStdOut, - bool& gotStdErr) + bool& gotStdErr, + bool running) { if(this->StdErrorBuffer.empty() && this->StdOutBuffer.empty()) { @@ -91,6 +92,27 @@ int cmProcess::GetNextOutputLine(std::string& stdOutLine, this->StdOutBuffer.begin(); std::vector<char>::iterator erriter = this->StdErrorBuffer.begin(); + + //If process terminated, flush the buffer + if(!running) + { + if(!this->StdErrorBuffer.empty()) + { + gotStdErr = true; + stdErrLine.append(&this->StdErrorBuffer[0], this->StdErrorBuffer.size()); + this->StdErrorBuffer.erase(this->StdErrorBuffer.begin(), + this->StdErrorBuffer.end()); + } + if(!this->StdOutBuffer.empty()) + { + gotStdOut = true; + stdOutLine.append(&this->StdOutBuffer[0], this->StdOutBuffer.size()); + this->StdOutBuffer.erase(this->StdOutBuffer.begin(), + this->StdOutBuffer.end()); + } + return cmsysProcess_Pipe_None; + } + // Check for a newline in stdout. for(;outiter != this->StdOutBuffer.end(); ++outiter) { @@ -145,7 +167,7 @@ int cmProcess::GetNextOutputLine(std::string& stdOutLine, } // return true if there is a new line of data // return false if there is no new data -void cmProcess::CheckOutput(double timeout) +bool cmProcess::CheckOutput(double timeout) { // Wait for data from the process. int length; @@ -159,7 +181,7 @@ void cmProcess::CheckOutput(double timeout) { // Timeout has been exceeded. this->LastOutputPipe = pipe; - return; + return true; } else if(pipe == cmsysProcess_Pipe_STDOUT) { @@ -180,17 +202,17 @@ void cmProcess::CheckOutput(double timeout) if(!this->StdOutBuffer.empty()) { this->LastOutputPipe = cmsysProcess_Pipe_STDOUT; - return; + return false; } else if(!this->StdErrorBuffer.empty()) { this->LastOutputPipe = cmsysProcess_Pipe_STDERR; - return; + return false; } else { this->LastOutputPipe = cmsysProcess_Pipe_None; - return; + return false; } } } |