diff options
author | Brad King <brad.king@kitware.com> | 2018-01-17 16:17:28 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2018-01-17 16:20:24 (GMT) |
commit | a6e9b9c9e4460f77fc173a3610b167e15f66f4ec (patch) | |
tree | 4e6296c412358a977ab4d7d14ca44ff809a35266 /Source/CTest | |
parent | c10119df62cf212f9274c6a5c0af609bae4f1b03 (diff) | |
download | CMake-a6e9b9c9e4460f77fc173a3610b167e15f66f4ec.zip CMake-a6e9b9c9e4460f77fc173a3610b167e15f66f4ec.tar.gz CMake-a6e9b9c9e4460f77fc173a3610b167e15f66f4ec.tar.bz2 |
CTest: Fix process output read error cases
The libuv documentation states that the stream read callback may
be called with `nread == 0` for EAGAIN. Handle this gracefully.
It also states that the callee is responsible for closing the
stream on error. Always close the stream for `nread < 0`.
Diffstat (limited to 'Source/CTest')
-rw-r--r-- | Source/CTest/cmProcess.cxx | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Source/CTest/cmProcess.cxx b/Source/CTest/cmProcess.cxx index 4454715..e332a77 100644 --- a/Source/CTest/cmProcess.cxx +++ b/Source/CTest/cmProcess.cxx @@ -244,6 +244,10 @@ void cmProcess::OnRead(ssize_t nread, const uv_buf_t* buf) return; } + if (nread == 0) { + return; + } + // The process will provide no more data. if (nread != UV_EOF) { auto error = static_cast<int>(nread); @@ -257,6 +261,7 @@ void cmProcess::OnRead(ssize_t nread, const uv_buf_t* buf) } this->ReadHandleClosed = true; + this->PipeReader.reset(); if (this->ProcessHandleClosed) { uv_timer_stop(this->Timer); this->Runner.FinalizeTest(); |