aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/cpp/blaze.cc
diff options
context:
space:
mode:
authorGravatar Chongyu Zhu <i@lembacon.com>2016-09-21 11:01:14 +0000
committerGravatar Laszlo Csomor <laszlocsomor@google.com>2016-09-21 11:51:35 +0000
commitfefd2329f4812bcb513294fdf417fc726a86ddfd (patch)
treec5291668fab87cc9804128d071f67308c3db484e /src/main/cpp/blaze.cc
parente5f59b4decf6ba483a4158b80e4a7adf96d0f52c (diff)
Use nanosleep(2) instead of poll(2) to sleep.
Starting with macOS Sierra developer beta 4, the behavior of poll(2) was changed, such that poll(2) will return immediately regardless the timeout if there is no file descriptor. This fixes #1767. And, this should be a better solution for Homebrew/homebrew-core#5041. Closes #1803. -- Reviewed-on: https://github.com/bazelbuild/bazel/pull/1803 MOS_MIGRATED_REVID=133816294
Diffstat (limited to 'src/main/cpp/blaze.cc')
-rw-r--r--src/main/cpp/blaze.cc11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/main/cpp/blaze.cc b/src/main/cpp/blaze.cc
index b5a330a2f8..c18968d5f8 100644
--- a/src/main/cpp/blaze.cc
+++ b/src/main/cpp/blaze.cc
@@ -31,7 +31,6 @@
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
-#include <poll.h>
#include <sched.h>
#include <signal.h>
#include <stdarg.h>
@@ -1070,7 +1069,10 @@ static void StartServerAndConnect(BlazeServer *server) {
}
fputc('.', stderr);
fflush(stderr);
- poll(NULL, 0, 1000); // sleep 100ms. (usleep(3) is obsolete.)
+ struct timespec ts;
+ ts.tv_sec = 0;
+ ts.tv_nsec = 100 * 1000 * 1000;
+ nanosleep(&ts, NULL);
if (!server_startup->IsStillAlive()) {
fprintf(stderr, "\nunexpected pipe read status: %s\n"
"Server presumed dead. Now printing '%s':\n",
@@ -1094,7 +1096,10 @@ static bool WaitForServerDeath(pid_t pid, int wait_time_secs) {
}
pdie(blaze_exit_code::INTERNAL_ERROR, "could not be killed");
}
- poll(NULL, 0, 100); // sleep 100ms. (usleep(3) is obsolete.)
+ struct timespec ts;
+ ts.tv_sec = 0;
+ ts.tv_nsec = 100 * 1000 * 1000;
+ nanosleep(&ts, NULL);
}
return false;
}