From d7f0424d2ce833d5924cbfc165d506717e222492 Mon Sep 17 00:00:00 2001 From: Bryan Roe Date: Tue, 27 Aug 2019 15:00:18 -0700 Subject: [PATCH] Updated crash handler on linux, so that if a core file would've been generated on crash, it will reset/restart the signal handler, so that a core file will be generated after logging the crash. --- microstack/ILibParsers.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/microstack/ILibParsers.c b/microstack/ILibParsers.c index 4445ec3..50f49fd 100644 --- a/microstack/ILibParsers.c +++ b/microstack/ILibParsers.c @@ -40,6 +40,10 @@ limitations under the License. #endif #endif +#ifndef WIN32 +#include +#endif + #ifdef _MINCORE #define strncmp(a,b,c) strcmp(a,b) #endif @@ -2228,6 +2232,7 @@ void ILib_WindowsExceptionDebugEx(ILib_DumpEnabledContext *dumpEnabledExceptionC char ILib_POSIX_CrashParamBuffer[5 * sizeof(void*)]; void ILib_POSIX_CrashHandler(int code) { + struct rlimit r; char msgBuffer[16384]; int msgLen = 0; void *buffer[100]; @@ -2320,7 +2325,22 @@ void ILib_POSIX_CrashHandler(int code) } } msgBuffer[msgLen] = 0; - ILIBCRITICALEXITMSG(254, msgBuffer); + + if (getrlimit(RLIMIT_CORE, &r) == 0 && r.rlim_cur != 0) + { + ILIBLOGMESSSAGE(msgBuffer); + + struct sigaction act; + memset(&act, 0, sizeof(act)); + act.sa_sigaction = SIG_DFL; + act.sa_flags = SA_RESTART; + sigemptyset(&act.sa_mask); + sigaction(SIGSEGV, &act, NULL); + } + else + { + ILIBCRITICALEXITMSG(254, msgBuffer); + } } char* ILib_POSIX_InstallCrashHandler(char *exename) {