summaryrefslogtreecommitdiff
path: root/src/hostname
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2018-07-20 15:00:02 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2018-07-20 15:00:02 +0900
commitb22c8bfcd4e3486271214f5ac27ae0c47e7f25c3 (patch)
tree6bce1381a42a276625f07805be5d8ed53e5405ad /src/hostname
parent50008ae48a8bf80c576b44bd36d176832b66669f (diff)
downloadsystemd-b22c8bfcd4e3486271214f5ac27ae0c47e7f25c3.tar.gz
hostname: set sd_event_add_signal()
Diffstat (limited to 'src/hostname')
-rw-r--r--src/hostname/hostnamed.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/hostname/hostnamed.c b/src/hostname/hostnamed.c
index ee51002ece..b98f962ad2 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)