mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-09-27 04:09:36 +03:00
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`.
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user