Skip to content

Commit

Permalink
Implement SigPrintf on Windows.
Browse files Browse the repository at this point in the history
--
Change-Id: I6ff757500085daa4c440a3ef41d02e6c664b9f3d
Reviewed-on: https://cr.bazel.build/9466
PiperOrigin-RevId: 150857712
MOS_MIGRATED_REVID=150857712
  • Loading branch information
dslomov authored and hermione521 committed Mar 22, 2017
1 parent 1fbef39 commit 5387c73
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/main/cpp/blaze_util_windows.cc
Original file line number Diff line number Diff line change
Expand Up @@ -235,17 +235,18 @@ ATTRIBUTE_NORETURN void SignalHandler::PropagateSignalOrExit(int exit_code) {
// in case the Blaze server has written a partial line.
void SigPrintf(const char *format, ...) {
#ifdef COMPILER_MSVC
// TODO(bazel-team): implement this.
int stderr_fileno = _fileno(stderr);
#else // not COMPILER_MSVC
int stderr_fileno = STDERR_FILENO;
#endif
char buf[1024];
va_list ap;
va_start(ap, format);
int r = vsnprintf(buf, sizeof buf, format, ap);
va_end(ap);
if (write(STDERR_FILENO, buf, r) <= 0) {
if (write(stderr_fileno, buf, r) <= 0) {
// We don't care, just placate the compiler.
}
#endif // COMPILER_MSVC
}

static void PrintError(const string& op) {
Expand Down

0 comments on commit 5387c73

Please sign in to comment.