diff options
author | Christian Göttsche <cgzones@googlemail.com> | 2020-09-10 00:17:59 +0200 |
---|---|---|
committer | cgzones <cgzones@googlemail.com> | 2020-09-17 21:54:21 +0200 |
commit | 5d4061732f25863d78cca06968cd938ae468b8bf (patch) | |
tree | f92c46629413216edf6af1aa034c2d704b0ed01b | |
parent | 00665e2a2b9c6efca6cd1f1dbaca0a91ccb31534 (diff) |
Allow third party sigsegv handler
For example from sanitizers.
-rw-r--r-- | CRT.c | 8 | ||||
-rw-r--r-- | CRT.h | 1 | ||||
-rw-r--r-- | linux/LinuxCRT.c | 6 |
3 files changed, 13 insertions, 2 deletions
@@ -552,6 +552,8 @@ void CRT_restorePrivileges() { // TODO: pass an instance of Settings instead. +struct sigaction old_sigsegv_handler; + void CRT_init(int delay, int colorScheme, bool allowUnicode) { initscr(); noecho(); @@ -605,7 +607,11 @@ void CRT_init(int delay, int colorScheme, bool allowUnicode) { } } #ifndef DEBUG - signal(11, CRT_handleSIGSEGV); + struct sigaction act; + sigemptyset (&act.sa_mask); + act.sa_flags = (int)SA_RESETHAND; + act.sa_handler = CRT_handleSIGSEGV; + sigaction (SIGSEGV, &act, &old_sigsegv_handler); #endif signal(SIGTERM, CRT_handleSIGTERM); signal(SIGQUIT, CRT_handleSIGTERM); @@ -108,6 +108,7 @@ typedef enum ColorElements_ { void CRT_fatalError(const char* note) __attribute__ ((noreturn)); +extern struct sigaction old_sigsegv_handler; void CRT_handleSIGSEGV(int sgn); #define KEY_ALT(x) (KEY_F(64 - 26) + (x - 'A')) diff --git a/linux/LinuxCRT.c b/linux/LinuxCRT.c index c65b7822..dbfad27f 100644 --- a/linux/LinuxCRT.c +++ b/linux/LinuxCRT.c @@ -7,6 +7,8 @@ in the source distribution for its full text. #include "config.h" #include "CRT.h" + +#include <signal.h> #include <stdio.h> #include <stdlib.h> #ifdef HAVE_EXECINFO_H @@ -32,5 +34,7 @@ void CRT_handleSIGSEGV(int sgn) { fprintf(stderr, "\nUnfortunately, you seem to be using an unsupported platform!"); fprintf(stderr, "\nPlease contact your platform package maintainer!\n\n"); #endif - abort(); + + /* Call old sigsegv handler; may be default exit or third party one (e.g. ASAN) */ + sigaction (SIGSEGV, &old_sigsegv_handler, NULL); } |