* src/crash.c
authorLuke Plant <L.Plant.98@cantab.net>
Wed, 30 Jul 2003 01:11:23 +0000 (01:11 +0000)
committerLuke Plant <L.Plant.98@cantab.net>
Wed, 30 Jul 2003 01:11:23 +0000 (01:11 +0000)
* src/main.c
o added/moved signal handlers for SIGTERM (normal kill command) and
  SIGINT (Ctl-c) to be used even without --enable-crash-dialog,
    fixing bug 166

src/crash.c
src/main.c

index f4928557a1bae831d68cb1a685dbbd93a52c990e..77a73cc324238123871ac18f893a013eeb5b4e24 100644 (file)
@@ -115,11 +115,6 @@ void crash_install_handlers(void)
        sigaddset(&mask, SIGABRT);
 #endif
 
-#ifdef SIGTERM
-       signal(SIGTERM, crash_handler);
-       sigaddset(&mask, SIGTERM);
-#endif
-
        sigprocmask(SIG_UNBLOCK, &mask, 0);
 #endif /* CRASH_DIALOG */      
 }
index 0707335cc1d764d1d2f19f5ede1ced498f4e668d..ea62599606b9ddb748dc3f517f5f6cb30a06bd36 100644 (file)
@@ -136,6 +136,8 @@ static void open_compose_new                (const gchar    *address,
 
 static void send_queue                 (void);
 static void initial_processing         (FolderItem *item, gpointer data);
+static void quit_signal_handler         (int sig);
+static void install_basic_sighandlers   (void);
 
 #if 0
 /* for gettext */
@@ -186,6 +188,7 @@ int main(int argc, char *argv[])
        }
        crash_install_handlers();
 #endif
+       install_basic_sighandlers();
 
        /* check and create unix domain socket */
        lock_socket = prohibit_duplicate_launch();
@@ -913,3 +916,37 @@ static void send_queue(void)
                }
        }
 }
+
+static void quit_signal_handler(int sig)
+{
+       debug_print("Quitting on signal %d\n", sig);
+       clean_quit();
+}
+
+static void install_basic_sighandlers()
+{
+       sigset_t    mask;
+       struct sigaction act;
+
+       sigemptyset(&mask);
+
+#ifdef SIGTERM
+       sigaddset(&mask, SIGTERM);
+#endif
+#ifdef SIGINT
+       sigaddset(&mask, SIGINT);
+#endif
+
+       act.sa_handler = quit_signal_handler;
+       act.sa_mask    = mask;
+       act.sa_flags   = 0;
+
+#ifdef SIGTERM
+       sigaction(SIGTERM, &act, 0);
+#endif
+#ifdef SIGINT
+       sigaction(SIGINT, &act, 0);
+#endif 
+
+       sigprocmask(SIG_UNBLOCK, &mask, 0);
+}