summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Griebl <robert.griebl@qt.io>2020-02-04 19:17:15 +0100
committerDominik Holland <dominik.holland@qt.io>2020-02-05 17:06:21 +0100
commit9bc74981bdaa3c1b88cb9ef96c865030c5ad3f79 (patch)
tree075f575041297cc02ce193976e0d93405eabab9a
parentdf2bd93f00ac4f8f628e5eeecf3527d6e95815a3 (diff)
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 <dominik.holland@qt.io>
-rw-r--r--src/common-lib/crashhandler.cpp6
1 files changed, 6 insertions, 0 deletions
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();