summaryrefslogtreecommitdiff
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 15:20:03 +0100
commit1379d100e1db51eb5a7f483cde694504f9d3d9c1 (patch)
tree995a0553de616fc400504fc9ac016a7c8ee23364
parent26884ef4eaa545ba3d29fa1e62af1fb356bed998 (diff)
parent6d9eabec485ac1f42515f7ce016977debc70df98 (diff)
downloadqtapplicationmanager-1379d100e1db51eb5a7f483cde694504f9d3d9c1.tar.gz
Merge "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();