From 9bc74981bdaa3c1b88cb9ef96c865030c5ad3f79 Mon Sep 17 00:00:00 2001 From: Robert Griebl Date: Tue, 4 Feb 2020 19:17:15 +0100 Subject: Make sure to kill any child processes when the main AM process crashes. This will handle all the usual suspects, but it will not be able to handle SIGKILL. Please note: this is Unix-only for now. Change-Id: I1fcac4dd8ddf2ef12d988012b04c2cb74b6f5f35 Reviewed-by: Dominik Holland --- src/common-lib/crashhandler.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/common-lib/crashhandler.cpp b/src/common-lib/crashhandler.cpp index 480dca9a..7f3ca903 100644 --- a/src/common-lib/crashhandler.cpp +++ b/src/common-lib/crashhandler.cpp @@ -187,6 +187,9 @@ static void initBacktrace() // 4 means to remove 4 stack frames: this way the backtrace starts at std::terminate crashHandler(buffer, 4); }); + + // create a new process group, so that we are able to kill all children with ::kill(0, ...) + setpgid(0, 0); } static void printMsgToConsole(const char *format, ...) Q_ATTRIBUTE_FORMAT_PRINTF(1, 2); @@ -417,6 +420,9 @@ static void crashHandler(const char *why, int stackFramesToIgnore) printCrashInfo(Dlt, why, stackFramesToIgnore); } + // make sure to kill our sub-process as well + kill(0, SIGABRT); + if (dumpCore) { fprintf(stderr, "\n > the process will be aborted (core dumped)\n\n"); abort(); -- cgit v1.2.3