From 2e3e3a47b91a2604760102703384b89150b98961 Mon Sep 17 00:00:00 2001 From: Thad House Date: Thu, 1 Nov 2018 01:55:26 -0700 Subject: [PATCH] Use a kill -9 after attemting a safe kill (#1397) Should fix some deploy deadlocks. --- hal/src/main/native/athena/HAL.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/hal/src/main/native/athena/HAL.cpp b/hal/src/main/native/athena/HAL.cpp index 2fc49a20c2..adb22963fe 100644 --- a/hal/src/main/native/athena/HAL.cpp +++ b/hal/src/main/native/athena/HAL.cpp @@ -308,16 +308,16 @@ static bool killExistingProgram(int timeout, int mode) { std::this_thread::sleep_for(std::chrono::milliseconds(timeout)); if (kill(pid, 0) == 0) { // still not successfull - if (mode == 0) { - wpi::outs() << "FRC pid " << pid << " did not die within " << timeout - << "ms. Aborting\n"; - return 0; // just fail - } else if (mode == 1) { // kill -9 it - kill(pid, SIGKILL); - } else { - wpi::outs() << "WARNING: FRC pid " << pid << " did not die within " - << timeout << "ms.\n"; + wpi::outs() << "FRC pid " << pid << " did not die within " << timeout + << "ms. Force killing with kill -9\n"; + // Force kill -9 + auto forceKill = kill(pid, SIGKILL); + if (forceKill != 0) { + auto errorMsg = std::strerror(forceKill); + wpi::outs() << "Kill -9 error: " << errorMsg << "\n"; } + // Give a bit of time for the kill to take place + std::this_thread::sleep_for(std::chrono::milliseconds(250)); } } }