mirror of https://github.com/xzeldon/htop.git
Allow third party sigsegv handler
For example from sanitizers.
This commit is contained in:
parent
00665e2a2b
commit
5d4061732f
8
CRT.c
8
CRT.c
|
@ -552,6 +552,8 @@ void CRT_restorePrivileges() {
|
||||||
|
|
||||||
// TODO: pass an instance of Settings instead.
|
// TODO: pass an instance of Settings instead.
|
||||||
|
|
||||||
|
struct sigaction old_sigsegv_handler;
|
||||||
|
|
||||||
void CRT_init(int delay, int colorScheme, bool allowUnicode) {
|
void CRT_init(int delay, int colorScheme, bool allowUnicode) {
|
||||||
initscr();
|
initscr();
|
||||||
noecho();
|
noecho();
|
||||||
|
@ -605,7 +607,11 @@ void CRT_init(int delay, int colorScheme, bool allowUnicode) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifndef DEBUG
|
#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
|
#endif
|
||||||
signal(SIGTERM, CRT_handleSIGTERM);
|
signal(SIGTERM, CRT_handleSIGTERM);
|
||||||
signal(SIGQUIT, CRT_handleSIGTERM);
|
signal(SIGQUIT, CRT_handleSIGTERM);
|
||||||
|
|
1
CRT.h
1
CRT.h
|
@ -108,6 +108,7 @@ typedef enum ColorElements_ {
|
||||||
|
|
||||||
void CRT_fatalError(const char* note) __attribute__ ((noreturn));
|
void CRT_fatalError(const char* note) __attribute__ ((noreturn));
|
||||||
|
|
||||||
|
extern struct sigaction old_sigsegv_handler;
|
||||||
void CRT_handleSIGSEGV(int sgn);
|
void CRT_handleSIGSEGV(int sgn);
|
||||||
|
|
||||||
#define KEY_ALT(x) (KEY_F(64 - 26) + (x - 'A'))
|
#define KEY_ALT(x) (KEY_F(64 - 26) + (x - 'A'))
|
||||||
|
|
|
@ -7,6 +7,8 @@ in the source distribution for its full text.
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "CRT.h"
|
#include "CRT.h"
|
||||||
|
|
||||||
|
#include <signal.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#ifdef HAVE_EXECINFO_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, "\nUnfortunately, you seem to be using an unsupported platform!");
|
||||||
fprintf(stderr, "\nPlease contact your platform package maintainer!\n\n");
|
fprintf(stderr, "\nPlease contact your platform package maintainer!\n\n");
|
||||||
#endif
|
#endif
|
||||||
abort();
|
|
||||||
|
/* Call old sigsegv handler; may be default exit or third party one (e.g. ASAN) */
|
||||||
|
sigaction (SIGSEGV, &old_sigsegv_handler, NULL);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue