From 754f0269355c10109f62a1b4a3a93558cfb7449f Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Fri, 20 Jul 2018 14:59:23 +0900 Subject: [PATCH 1/3] timedate: set sd_event_add_signal() --- src/timedate/timedated.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/timedate/timedated.c b/src/timedate/timedated.c index ad662fb1cf2..4beded5de01 100644 --- a/src/timedate/timedated.c +++ b/src/timedate/timedated.c @@ -20,6 +20,7 @@ #include "list.h" #include "path-util.h" #include "selinux-util.h" +#include "signal-util.h" #include "string-util.h" #include "strv.h" #include "unit-def.h" @@ -909,13 +910,23 @@ int main(int argc, char *argv[]) { goto finish; } + assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGTERM, SIGINT, -1) >= 0); + r = sd_event_default(&event); if (r < 0) { log_error_errno(r, "Failed to allocate event loop: %m"); goto finish; } - sd_event_set_watchdog(event, true); + (void) sd_event_set_watchdog(event, true); + + r = sd_event_add_signal(event, NULL, SIGINT, NULL, NULL); + if (r < 0) + return r; + + r = sd_event_add_signal(event, NULL, SIGTERM, NULL, NULL); + if (r < 0) + return r; r = connect_bus(&context, event, &bus); if (r < 0) From 50008ae48a8bf80c576b44bd36d176832b66669f Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Fri, 20 Jul 2018 14:59:36 +0900 Subject: [PATCH 2/3] locale: set sd_event_add_signal() --- src/locale/localed.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/locale/localed.c b/src/locale/localed.c index b8f95b69a62..71115c59d78 100644 --- a/src/locale/localed.c +++ b/src/locale/localed.c @@ -21,6 +21,7 @@ #include "macro.h" #include "path-util.h" #include "selinux-util.h" +#include "signal-util.h" #include "string-util.h" #include "strv.h" #include "user-util.h" @@ -738,13 +739,23 @@ int main(int argc, char *argv[]) { goto finish; } + assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGTERM, SIGINT, -1) >= 0); + r = sd_event_default(&event); if (r < 0) { log_error_errno(r, "Failed to allocate event loop: %m"); goto finish; } - sd_event_set_watchdog(event, true); + (void) sd_event_set_watchdog(event, true); + + r = sd_event_add_signal(event, NULL, SIGINT, NULL, NULL); + if (r < 0) + return r; + + r = sd_event_add_signal(event, NULL, SIGTERM, NULL, NULL); + if (r < 0) + return r; r = connect_bus(&context, event, &bus); if (r < 0) From b22c8bfcd4e3486271214f5ac27ae0c47e7f25c3 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Fri, 20 Jul 2018 15:00:02 +0900 Subject: [PATCH 3/3] hostname: set sd_event_add_signal() --- src/hostname/hostnamed.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/hostname/hostnamed.c b/src/hostname/hostnamed.c index ee51002ece3..b98f962ad29 100644 --- a/src/hostname/hostnamed.c +++ b/src/hostname/hostnamed.c @@ -15,6 +15,7 @@ #include "parse-util.h" #include "path-util.h" #include "selinux-util.h" +#include "signal-util.h" #include "strv.h" #include "user-util.h" #include "util.h" @@ -670,13 +671,23 @@ int main(int argc, char *argv[]) { goto finish; } + assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGTERM, SIGINT, -1) >= 0); + r = sd_event_default(&event); if (r < 0) { log_error_errno(r, "Failed to allocate event loop: %m"); goto finish; } - sd_event_set_watchdog(event, true); + (void) sd_event_set_watchdog(event, true); + + r = sd_event_add_signal(event, NULL, SIGINT, NULL, NULL); + if (r < 0) + return r; + + r = sd_event_add_signal(event, NULL, SIGTERM, NULL, NULL); + if (r < 0) + return r; r = connect_bus(&context, event, &bus); if (r < 0)