Skip to content

Commit

Permalink
blaze_util_posix: handle killpg failures (bazelbuild#18403)
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.

Closes bazelbuild#18299.

PiperOrigin-RevId: 530615358
Change-Id: I4ddf9996ce80520ff19c306fe95429550e931a8b

Co-authored-by: Son Luong Ngoc <[email protected]>
  • Loading branch information
keertk and sluongng authored May 17, 2023
1 parent eb75087 commit 27b4fe8
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 @@ -724,7 +724,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 27b4fe8

Please sign in to comment.