From 3d9a70ca68c1e0eeeec640e90625deb68245a64e Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Tue, 23 Aug 2011 21:06:51 -0400 Subject: [PATCH] Handle sigsegv as well. --- os_posix.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/os_posix.cpp b/os_posix.cpp index 684ffac..c072d5d 100644 --- a/os_posix.cpp +++ b/os_posix.cpp @@ -144,13 +144,16 @@ struct Interrupts : set(false), sig_int(NULL), sig_hup(NULL), - sig_term(NULL) + sig_term(NULL), + sig_segv(NULL), + handler(NULL) {} bool set; void (*sig_int)(int); void (*sig_hup)(int); void (*sig_term)(int); + void (*sig_segv)(int); void (*handler)(int); }; @@ -162,17 +165,24 @@ static void InterruptHandler(int sig) interrupts.handler(sig); } if (sig == SIGINT) { - if (!interrupts.sig_int) + if (!interrupts.sig_int) { exit(sig); + } interrupts.sig_int(sig); } else if (sig == SIGHUP) { - if (!interrupts.sig_hup) + if (!interrupts.sig_hup) { exit(sig); + } interrupts.sig_hup(sig); } else if (sig == SIGTERM) { - if (!interrupts.sig_term) + if (!interrupts.sig_term) { exit(sig); + } interrupts.sig_term(sig); + } else if (sig == SIGSEGV) { + if (interrupts.sig_segv) { + interrupts.sig_segv(sig); + } } } @@ -198,6 +208,7 @@ CatchInterrupts(void (*func)(int)) SET_IF_NOT_IGNORED(SIGINT, interrupts.sig_int); SET_IF_NOT_IGNORED(SIGHUP, interrupts.sig_hup); SET_IF_NOT_IGNORED(SIGTERM, interrupts.sig_term); + SET_IF_NOT_IGNORED(SIGSEGV, interrupts.sig_segv); interrupts.set = true; #undef SET_IF_NOT_IGNORED -- 2.43.0