Add SIGTERM signal handling 49/13249/3
authortaesub.kim <taesub.kim@samsung.com>
Mon, 2 Dec 2013 01:39:23 +0000 (10:39 +0900)
committertaesub kim <taesub.kim@samsung.com>
Mon, 30 Dec 2013 04:06:27 +0000 (20:06 -0800)
Change-Id: Id9c235cf5f9718a05467e4286d0dd37a05d703ae
Signed-off-by: Taesub Kim <taesub.kim@samsung.com>
packaging/net-config.spec
src/main.c

index c19d099..c927ae3 100644 (file)
@@ -1,6 +1,6 @@
 Name:       net-config
 Summary:    TIZEN Network Configuration Module
-Version:    0.1.90_27
+Version:    0.1.90_28
 Release:    1
 Group:      System/Network
 License:    Apache License Version 2.0
index 1f9fcfc..ccdc669 100644 (file)
@@ -38,6 +38,29 @@ static GMainLoop *main_loop = NULL;
 
 static int no_fork = FALSE;
 
+void netconfig_signal_handler_SIGTERM(int signum)
+{
+       g_main_loop_quit(main_loop);
+}
+
+int netconfig_register_signal_handler_SIGTERM(void)
+{
+       struct sigaction sigset;
+
+       sigemptyset(&sigset.sa_mask);
+       sigaddset( &sigset.sa_mask, SIGTERM );
+       sigset.sa_flags = 0;
+       sigset.sa_handler = netconfig_signal_handler_SIGTERM;
+
+       if (sigaction( SIGTERM, &sigset, NULL) < 0) {
+               ERR("Sigaction for SIGTERM failed [%s]", strerror( errno ));
+               return -1;
+       }
+
+       INFO( "Handler for SIGTERM ok" );
+       return 0;
+}
+
 int netconfig_test_input_parameters(int argc, char* argv[])
 {
         struct option tab[] = {
@@ -95,6 +118,10 @@ int main(int argc, char* argv[])
        if (netconfig_network_statistics_create_and_init(connection) == NULL)
                return -1;
 
+       /* Register SIGCHLD signal handler function */
+       if (netconfig_register_signal_handler_SIGTERM() != 0)
+               return -1;
+
        /* If its environment uses Emulator, network configuration is set by emulator default */
        netconfig_emulator_test_and_start();