From 18af4e627263d02a2e02f28578b3d971a32bad21 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Sat, 16 Jul 2011 10:13:49 +1000 Subject: [PATCH] Re-enable signal handlers once the custom sighandler has been hit to make it possible to still kill cgminer. --- main.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index d989abd0..eda21aad 100644 --- a/main.c +++ b/main.c @@ -186,6 +186,8 @@ static char longpoll_block[37]; static char blank[37]; static char datestamp[40]; +struct sigaction termhandler, inthandler; + static void applog_and_exit(const char *fmt, ...) { va_list ap; @@ -810,6 +812,9 @@ void kill_work(void) static void sighandler(int sig) { + /* Restore signal handlers so we can still quit if kill_work fails */ + sigaction(SIGTERM, &termhandler, NULL); + sigaction(SIGINT, &inthandler, NULL); kill_work(); } @@ -2099,8 +2104,8 @@ int main (int argc, char *argv[]) return 1; handler.sa_handler = &sighandler; - sigaction(SIGTERM, &handler, 0); - sigaction(SIGINT, &handler, 0); + sigaction(SIGTERM, &handler, &termhandler); + sigaction(SIGINT, &handler, &inthandler); gettimeofday(&total_tv_start, NULL); gettimeofday(&total_tv_end, NULL);