Skip to content

Commit 27b4fe8

Browse files
keertksluongng
andauthored
blaze_util_posix: handle killpg failures (#18403)
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 Co-authored-by: Son Luong Ngoc <[email protected]>
1 parent eb75087 commit 27b4fe8

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
@@ -724,7 +724,12 @@ void ReleaseLock(BlazeLock* blaze_lock) {
724724

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

0 commit comments

Comments
 (0)