From 34d88d96dc0e87a773bee8ea959d43074195af68 Mon Sep 17 00:00:00 2001 From: kremlin Date: Mon, 4 Aug 2014 21:37:30 -0500 Subject: (7) add set_signal_handlers() to bind functions during init this function calls attached the ones from the previous commit to the GLib runtime properly. since we are working solely in the default context (in terms on the GMainLoop) we are guaranteed the attached functions will only run once. --- src/interfaces/logind/logind.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/interfaces/logind') diff --git a/src/interfaces/logind/logind.c b/src/interfaces/logind/logind.c index a0b0343..da9e24b 100644 --- a/src/interfaces/logind/logind.c +++ b/src/interfaces/logind/logind.c @@ -142,6 +142,14 @@ gboolean unix_sig_terminate_handler(gpointer data) { return G_SOURCE_REMOVE; } +void set_signal_handlers() { + + /* we don't care about its descriptor, we never need to unregister these */ + g_unix_signal_add(SIGINT, unix_sig_terminate_handler, NULL); + g_unix_signal_add(SIGHUP, unix_sig_terminate_handler, NULL); + g_unix_signal_add(SIGTERM, unix_sig_terminate_handler, NULL); +} + int main() { logind_loop = g_main_loop_new(NULL, TRUE); -- cgit v1.2.3