static GMainLoop *loop;
-static void sig_quit(int signo)
+static gboolean handle_signal(gpointer data)
{
- _D("Received SIGTERM signal(%d).", signo);
- g_main_loop_quit(loop);
-}
+ long signo = (long) data;
-static void sig_usr1(int signo)
-{
- _D("Received SIGUSR1 signal %d. Storaged'll be finished.", signo);
+ _D("Received signal(%ld), Storaged'll be finished.", signo);
+
+ if (loop && g_main_loop_is_running(loop))
+ g_main_loop_quit(loop);
- g_main_loop_quit(loop);
+ return G_SOURCE_REMOVE;
}
void watchdog_notify(void)
gdbus_check_name_owner(NULL, STORAGED_BUS_NAME);
}
- signal(SIGTERM, sig_quit);
- signal(SIGUSR1, sig_usr1);
+ g_unix_signal_add(SIGTERM, handle_signal, (gpointer) SIGTERM);
+ g_unix_signal_add(SIGUSR1, handle_signal, (gpointer) SIGUSR1);
timer = g_timeout_add(WATCHDOG_TIMEOUT * 1000, watchdog_cb, NULL);
if (timer > 0) {