Skip to content

Commit 09e3a81

Browse files
sluongngcopybara-github
authored andcommitted
blaze_util_posix: handle killpg failures
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 #18299. PiperOrigin-RevId: 530615358 Change-Id: I4ddf9996ce80520ff19c306fe95429550e931a8b
1 parent 5664497 commit 09e3a81

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/main/cpp/blaze_util_posix.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,12 @@ void ReleaseLock(BlazeLock* blaze_lock) {
726726

727727
bool KillServerProcess(int pid, const blaze_util::Path& output_base) {
728728
// Kill the process and make sure it's dead before proceeding.
729-
killpg(pid, SIGKILL);
729+
errno = 0;
730+
if (killpg(pid, SIGKILL) == -1) {
731+
BAZEL_DIE(blaze_exit_code::LOCAL_ENVIRONMENTAL_ERROR)
732+
<< "Attempted to kill stale server process (pid=" << pid
733+
<< ") using SIGKILL: " << GetLastErrorString();
734+
}
730735
if (!AwaitServerProcessTermination(pid, output_base,
731736
kPostKillGracePeriodSeconds)) {
732737
BAZEL_DIE(blaze_exit_code::LOCAL_ENVIRONMENTAL_ERROR)

0 commit comments

Comments
 (0)