diff options
author | 2017-03-02 09:09:09 +0000 | |
---|---|---|
committer | 2017-03-02 13:32:16 +0000 | |
commit | 508af301b3d7c1465189a0edfe4707a1c261a658 (patch) | |
tree | a426a81dd791f3053dd9cb86d5f0860992814a4f /src/main/cpp/blaze.cc | |
parent | 4f2b41d3f5fe936833380a0446adb671b8a50b1f (diff) |
Bazel client: do not use `errno`.
Do not use `errno` in platform-independent code,
because Windows API functions don't set it.
This change abstracts away error handling and the
functions whose `errno` result we care about, will
set an input error variable.
Fixes https://github.com/bazelbuild/bazel/issues/2506
--
PiperOrigin-RevId: 148977873
MOS_MIGRATED_REVID=148977873
Diffstat (limited to 'src/main/cpp/blaze.cc')
-rw-r--r-- | src/main/cpp/blaze.cc | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/main/cpp/blaze.cc b/src/main/cpp/blaze.cc index 246bf53621..eec8f47ffc 100644 --- a/src/main/cpp/blaze.cc +++ b/src/main/cpp/blaze.cc @@ -27,7 +27,6 @@ #include <assert.h> #include <ctype.h> -#include <errno.h> #include <fcntl.h> #include <limits.h> #include <stdarg.h> @@ -1527,8 +1526,9 @@ void GrpcBlazeServer::CancelThread() { while (running) { char buf; - int bytes_read = pipe_->Receive(&buf, 1); - if (bytes_read < 0 && errno == EINTR) { + int error; + int bytes_read = pipe_->Receive(&buf, 1, &error); + if (bytes_read < 0 && error == blaze_util::IPipe::INTERRUPTED) { continue; } else if (bytes_read != 1) { pdie(blaze_exit_code::INTERNAL_ERROR, @@ -1665,8 +1665,9 @@ unsigned int GrpcBlazeServer::Communicate() { if (!response.standard_output().empty()) { size_t size = response.standard_output().size(); - size_t r = fwrite(response.standard_output().c_str(), 1, size, stdout); - if (r < size && errno == EPIPE) { + if (blaze_util::WriteToStdOutErr(response.standard_output().c_str(), size, + /* to_stdout */ true) == + blaze_util::WriteResult::BROKEN_PIPE) { pipe_broken_now = true; broken_pipe_name = "standard output"; } @@ -1674,8 +1675,9 @@ unsigned int GrpcBlazeServer::Communicate() { if (!response.standard_error().empty()) { size_t size = response.standard_error().size(); - size_t r = fwrite(response.standard_error().c_str(), 1, size, stderr); - if (r < size && errno == EPIPE) { + if (blaze_util::WriteToStdOutErr(response.standard_error().c_str(), size, + /* to_stdout */ false) == + blaze_util::WriteResult::BROKEN_PIPE) { pipe_broken_now = true; broken_pipe_name = "standard error"; } |