From 9cf08623e3092fa19366e5c07fbe06898a59f039 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Fri, 26 Jan 2018 11:45:53 +0100 Subject: [PATCH] feat(SingleApplication): don't touch sockets when SIGABRT, SIGBUS or SIGSEGV is handled --- src/app/single-application/SingleApplication.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/app/single-application/SingleApplication.cpp b/src/app/single-application/SingleApplication.cpp index d64903ba4..b42285b51 100644 --- a/src/app/single-application/SingleApplication.cpp +++ b/src/app/single-application/SingleApplication.cpp @@ -256,11 +256,21 @@ void SingleApplicationPrivate::connectToPrimary (int msecs, char connectionType) return; } + // Dangerous signals. Exit directly after shared memory destruction. + // Don't touch sockets => avoid dead locks. + for (int crashSig : { SIGABRT, SIGBUS, SIGSEGV }) + if (signum == crashSig) { + for (SingleApplicationPrivate *d : sharedMem) + delete d->memory; + goto forceExit; + } + while (!sharedMem.empty()) { delete sharedMem.back(); sharedMem.pop_back(); } + forceExit: ::exit(128 + signum); }