aboutsummaryrefslogtreecommitdiffstats
path: root/src/interfaces/timedated/timedated.c
diff options
context:
space:
mode:
authorkremlin <ian@kremlin.cc>2014-08-05 10:37:30 +0800
committerkremlin <ian@kremlin.cc>2014-08-05 10:37:30 +0800
commit2ef2cfe10db118edc44aaea13d4af130aef77083 (patch)
treefce330f16f7b2bccf1e4cab14892e774f3943055 /src/interfaces/timedated/timedated.c
parent712eb32987872a6515e956246c0695fda032eb98 (diff)
downloadsystembsd-2ef2cfe10db118edc44aaea13d4af130aef77083.tar
systembsd-2ef2cfe10db118edc44aaea13d4af130aef77083.tar.gz
systembsd-2ef2cfe10db118edc44aaea13d4af130aef77083.tar.bz2
systembsd-2ef2cfe10db118edc44aaea13d4af130aef77083.tar.lz
systembsd-2ef2cfe10db118edc44aaea13d4af130aef77083.tar.xz
systembsd-2ef2cfe10db118edc44aaea13d4af130aef77083.tar.zst
systembsd-2ef2cfe10db118edc44aaea13d4af130aef77083.zip
(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.
Diffstat (limited to 'src/interfaces/timedated/timedated.c')
-rw-r--r--src/interfaces/timedated/timedated.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/interfaces/timedated/timedated.c b/src/interfaces/timedated/timedated.c
index 265a33f..32f040a 100644
--- a/src/interfaces/timedated/timedated.c
+++ b/src/interfaces/timedated/timedated.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() {
timedated_loop = g_main_loop_new(NULL, TRUE);