mirror of
https://github.com/Ylianst/MeshAgent
synced 2025-12-17 16:53:13 +00:00
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.
This commit is contained in:
@@ -40,6 +40,10 @@ limitations under the License.
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef WIN32
|
||||||
|
#include <sys/resource.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef _MINCORE
|
#ifdef _MINCORE
|
||||||
#define strncmp(a,b,c) strcmp(a,b)
|
#define strncmp(a,b,c) strcmp(a,b)
|
||||||
#endif
|
#endif
|
||||||
@@ -2228,6 +2232,7 @@ void ILib_WindowsExceptionDebugEx(ILib_DumpEnabledContext *dumpEnabledExceptionC
|
|||||||
char ILib_POSIX_CrashParamBuffer[5 * sizeof(void*)];
|
char ILib_POSIX_CrashParamBuffer[5 * sizeof(void*)];
|
||||||
void ILib_POSIX_CrashHandler(int code)
|
void ILib_POSIX_CrashHandler(int code)
|
||||||
{
|
{
|
||||||
|
struct rlimit r;
|
||||||
char msgBuffer[16384];
|
char msgBuffer[16384];
|
||||||
int msgLen = 0;
|
int msgLen = 0;
|
||||||
void *buffer[100];
|
void *buffer[100];
|
||||||
@@ -2320,7 +2325,22 @@ void ILib_POSIX_CrashHandler(int code)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
msgBuffer[msgLen] = 0;
|
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)
|
char* ILib_POSIX_InstallCrashHandler(char *exename)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user