Skip to content

Commit

Permalink
blaze_util_posix: handle killpg failures
Browse files Browse the repository at this point in the history
In case Bazel JVM server is stuck, it would be useful to know whether
the SIGKILL was sent successfully or not.

If not, log out the error message from errno.
  • Loading branch information
sluongng committed May 8, 2023
1 parent cc7848a commit a76aff4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/main/cpp/blaze_util_posix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,12 @@ void ReleaseLock(BlazeLock* blaze_lock) {

bool KillServerProcess(int pid, const blaze_util::Path& output_base) {
// Kill the process and make sure it's dead before proceeding.
killpg(pid, SIGKILL);
errno = 0;
if (killpg(pid, SIGKILL) == -1) {
BAZEL_DIE(blaze_exit_code::LOCAL_ENVIRONMENTAL_ERROR)
<< "Attempted to kill stale server process (pid=" << pid
<< ") using SIGKILL: " << GetLastErrorString();
}
if (!AwaitServerProcessTermination(pid, output_base,
kPostKillGracePeriodSeconds)) {
BAZEL_DIE(blaze_exit_code::LOCAL_ENVIRONMENTAL_ERROR)
Expand Down

0 comments on commit a76aff4

Please sign in to comment.