Really handle SIG_TERM outside the signal handler
authorThomas Jarosch <thomas.jarosch@intra2net.com>
Wed, 6 Oct 2010 14:05:29 +0000 (16:05 +0200)
committerThomas Jarosch <thomas.jarosch@intra2net.com>
Wed, 6 Oct 2010 14:05:29 +0000 (16:05 +0200)
src/main.cpp

index 5eb040d..ea70d7a 100644 (file)
@@ -29,6 +29,7 @@ Updater::Ptr updater;
 volatile bool need_config_reload = false;
 volatile bool exit_now = false;
 
+volatile bool caught_sig_term = false;
 volatile bool caught_sig_usr1 = false;
 volatile bool caught_sig_usr2 = false;
 volatile bool caught_sig_rtmin1 = false;
@@ -141,8 +142,7 @@ int shutdown()
  */
 void terminate(int param)
 {
-    updater->get_logger()->print_caught_sigterm();
-    exit_now = true;
+    caught_sig_term = true;
 } /*lint !e715 */
 
 
@@ -339,6 +339,12 @@ int main(int argc, char *argv[])
             // Go online - with webcheck
             is_online = true;
             webcheck_enabled = true;
+        } else if (caught_sig_term)
+        {
+            caught_sig_term = true;
+            updater->get_logger()->print_caught_sigterm();
+
+            exit_now = true;
         }
 
         // State handling