summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Griebl <robert.griebl@qt.io>2020-02-19 13:40:36 +0100
committerRobert Griebl <robert.griebl@qt.io>2020-02-19 13:40:36 +0100
commit6d9eabec485ac1f42515f7ce016977debc70df98 (patch)
tree76c16cc3c1e6aeb0423a5fce4d8377e31f1e637f
parent2f8a08e7d3c8e0a7136587fc8080ea2e1f8e4485 (diff)
parent6a1553e451890580db06b2c2d4939203ac349f8b (diff)
Merge remote-tracking branch 'gerrit/5.13' into 5.14
-rw-r--r--src/common-lib/crashhandler.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/common-lib/crashhandler.cpp b/src/common-lib/crashhandler.cpp
index 880c69b3..bdc227d8 100644
--- a/src/common-lib/crashhandler.cpp
+++ b/src/common-lib/crashhandler.cpp
@@ -364,6 +364,9 @@ static void initBacktraceUnix()
// 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 logCrashInfo(LogToDestination logTo, const char *why, int stackFramesToIgnore)
@@ -377,10 +380,17 @@ static void logCrashInfo(LogToDestination logTo, const char *why, int stackFrame
}
pid_t pid = getpid();
+#if defined(Q_OS_LINUX)
long tid = syscall(SYS_gettid);
+ bool isMainThread = (tid == pid);
+#else
+ long tid = -1;
+ bool isMainThread = pthread_main_np();
+#endif
pthread_t pthreadId = pthread_self();
char threadName[16];
- if (tid == pid)
+
+ if (isMainThread)
strcpy(threadName, "main");
else if (pthread_getname_np(pthreadId, threadName, sizeof(threadName)))
strcpy(threadName, "unknown");
@@ -543,6 +553,9 @@ static void crashHandler(const char *why, int stackFramesToIgnore)
logCrashInfo(Dlt, why, stackFramesToIgnore);
# endif
+ // make sure to kill our sub-process as well
+ kill(0, SIGABRT);
+
if (dumpCore) {
logMsg(Console, "\n > the process will be aborted (core dumped)\n\n");
abort();