aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/cpp/blaze_util_darwin.cc
diff options
context:
space:
mode:
authorGravatar mschaller <mschaller@google.com>2017-07-11 18:21:36 +0200
committerGravatar László Csomor <laszlocsomor@google.com>2017-07-12 08:48:38 +0200
commitfd37b512d3a899da531cb6ba2cc70543246940fe (patch)
treea0fdb66c7c9d0cde4b1e72e56d068fe9f4bf2575 /src/main/cpp/blaze_util_darwin.cc
parent937350211dcd55a4714ec32ebbf33fffcc42cdf2 (diff)
Ensure that shutdown commands end the server process before completion
This change ensures that the server process is terminated before the client process terminates, when evaluating a command that shuts down the server. When completing such a command, the server communicates to the client that the server will terminate itself by setting a termination_expected bit in the final RunResponse message. The client then waits up to 60s for the server process to actually terminate. If it does not, then the client SIGKILLs the server. Also makes the gRPC server stop accepting new commands before the shutdown command completes. Drive-by fix to comments on Search{Un,Null}aryOption. RELNOTES: Commands that shut down the server (like "shutdown") now ensure that the server process has terminated before the client process terminates. PiperOrigin-RevId: 161537480
Diffstat (limited to 'src/main/cpp/blaze_util_darwin.cc')
-rw-r--r--src/main/cpp/blaze_util_darwin.cc15
1 files changed, 5 insertions, 10 deletions
diff --git a/src/main/cpp/blaze_util_darwin.cc b/src/main/cpp/blaze_util_darwin.cc
index 075b48a1e0..008b721e0a 100644
--- a/src/main/cpp/blaze_util_darwin.cc
+++ b/src/main/cpp/blaze_util_darwin.cc
@@ -196,16 +196,11 @@ void WriteSystemSpecificProcessIdentifier(
const string& server_dir, pid_t server_pid) {
}
-bool VerifyServerProcess(
- int pid, const string& output_base, const string& install_base) {
- // TODO(lberki): This might accidentally kill an unrelated process if the
- // server died and the PID got reused.
- return true;
-}
-
-bool KillServerProcess(int pid) {
- killpg(pid, SIGKILL);
- return true;
+bool VerifyServerProcess(int pid, const string &output_base) {
+ // TODO(lberki): This only checks for the process's existence, not whether
+ // its start time matches. Therefore this might accidentally kill an
+ // unrelated process if the server died and the PID got reused.
+ return killpg(pid, 0) == 0;
}
// Sets a flag on path to exclude the path from Apple's automatic backup service