From 35abdb30d26f0bfb972c1712ee887a0f0fff6b97 Mon Sep 17 00:00:00 2001 From: John Darrington Date: Thu, 13 Jan 2005 13:02:26 +0000 Subject: [PATCH] Moved the SIGINT handler from casefile.c to main.c --- src/ChangeLog | 5 +++++ src/casefile.c | 6 +++--- src/main.c | 18 +++++++++++++++++- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 76e95763..80654946 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +Thu Jan 13 21:00:02 WST 2005 John Darrington + + * casefile.c main.c: Moved the SIGINT handler from casefile.c to + main.c. Removed the handler for SIGQUIT. + Mon Jan 10 14:43:45 WST 2005 John Darrington * casefile.c: Added a signal handler to delete temp files on SIGINT and SIGQUIT diff --git a/src/casefile.c b/src/casefile.c index 242fc385..5ad606a3 100644 --- a/src/casefile.c +++ b/src/casefile.c @@ -32,7 +32,6 @@ #include "misc.h" #include "settings.h" #include "var.h" -#include "signal.h" #ifdef HAVE_VALGRIND_VALGRIND_H #include @@ -727,6 +726,7 @@ full_write (int fd, const void *buffer_, size_t size) return bytes_written; } + /* Registers our exit handler with atexit() if it has not already been registered. */ static void @@ -736,12 +736,12 @@ register_atexit (void) if (!registered) { registered = 1; - signal (SIGQUIT, (sighandler_t) exit_handler); - signal (SIGINT, (sighandler_t) exit_handler); atexit (exit_handler); } } + + /* atexit() handler that closes and deletes our temporary files. */ static void diff --git a/src/main.c b/src/main.c index b09a200a..c5f9c34f 100644 --- a/src/main.c +++ b/src/main.c @@ -54,17 +54,26 @@ char curdate[12]; /* If a segfault happens, issue a message to that effect and halt */ void bug_handler(int sig); +/* Handle quit/term/int signals */ +void interrupt_handler(int sig); + /* Whether we're dropping down to interactive mode immediately because we hit end-of-file unexpectedly (or whatever). */ int start_interactive; + + + + /* Program entry point. */ int main (int argc, char **argv) { + signal (SIGSEGV, bug_handler); - signal (SIGFPE, bug_handler); + signal (SIGFPE, bug_handler); + signal (SIGINT, interrupt_handler); gsl_set_error_handler_off(); @@ -199,3 +208,10 @@ bug_handler(int sig UNUSED) break; } } + + +void +interrupt_handler(int sig UNUSED) +{ + err_hcf(0); +} -- 2.30.2