Unregister the NSM dummy DLT connection at exit
authorJannis Pohlmann <jannis.pohlmann@codethink.co.uk>
Wed, 1 Aug 2012 11:26:29 +0000 (12:26 +0100)
committerJannis Pohlmann <jannis.pohlmann@codethink.co.uk>
Wed, 1 Aug 2012 11:26:29 +0000 (12:26 +0100)
nsm-dummy/main.c

index ae33116..ad35fa6 100644 (file)
@@ -30,6 +30,15 @@ DLT_DECLARE_CONTEXT (nsm_dummy_context);
 
 
 
+static void
+unregister_dlt (void)
+{
+  DLT_UNREGISTER_CONTEXT (nsm_dummy_context);
+  DLT_UNREGISTER_APP ();
+}
+
+
+
 int
 main (int    argc,
       char **argv)
@@ -46,6 +55,9 @@ main (int    argc,
   DLT_REGISTER_CONTEXT (nsm_dummy_context, "NSMC",
                         "Context of the node state manager dummy itself");
 
+  /* have DLT unregistered at exit */
+  atexit (unregister_dlt);
+
   /* initialize the GType type system */
   g_type_init ();
 
@@ -106,9 +118,5 @@ main (int    argc,
   g_object_unref (consumer_service);
   g_object_unref (connection);
 
-  /* unregister the application and context with DLT */
-  DLT_UNREGISTER_CONTEXT (nsm_dummy_context);
-  DLT_UNREGISTER_APP ();
-
   return EXIT_SUCCESS;
 }