summaryrefslogtreecommitdiff
path: root/src/login/elogind.c
diff options
context:
space:
mode:
authorStefan Stefanović <stefanx2ovic@gmail.com>2018-11-09 08:50:01 +0100
committerSven Eden <sven.eden@prydeworx.com>2018-11-10 10:00:20 +0100
commitc35c7b3a589e8f7f99e9fd0e7e853210af5fea9c (patch)
treeb791330cb6a9ecdc532b38ed0d495360a1add5a0 /src/login/elogind.c
parent45f85d95ed11f4e85ee8519f8bedfb75d9e5bc73 (diff)
elogind: Use SIG_BLOCK before signal handler registration.
Diffstat (limited to 'src/login/elogind.c')
-rw-r--r--src/login/elogind.c38
1 files changed, 16 insertions, 22 deletions
diff --git a/src/login/elogind.c b/src/login/elogind.c
index d5cf63336..58040f353 100644
--- a/src/login/elogind.c
+++ b/src/login/elogind.c
@@ -398,6 +398,22 @@ int elogind_manager_new(Manager* m) {
if (r > -1)
r = manager_setup_cgroup(m);
+ /* Install our signal handler */
+ assert_se(sigprocmask_many(SIG_SETMASK, NULL, SIGINT, -1) >= 0);
+ r = sd_event_add_signal(m->event, NULL, SIGINT, elogind_signal_handler, m);
+ if (r < 0)
+ return log_error_errno(r, "Failed to register SIGINT handler: %m");
+
+ assert_se(sigprocmask_many(SIG_SETMASK, NULL, SIGQUIT, -1) >= 0);
+ r = sd_event_add_signal(m->event, NULL, SIGQUIT, elogind_signal_handler, m);
+ if (r < 0)
+ return log_error_errno(r, "Failed to register SIGQUIT handler: %m");
+
+ assert_se(sigprocmask_many(SIG_SETMASK, NULL, SIGTERM, -1) >= 0);
+ r = sd_event_add_signal(m->event, NULL, SIGTERM, elogind_signal_handler, m);
+ if (r < 0)
+ return log_error_errno(r, "Failed to register SIGTERM handler: %m");
+
return r;
}
@@ -453,25 +469,3 @@ void elogind_manager_reset_config(Manager* m) {
m->hibernate_delay_sec / USEC_PER_MINUTE);
#endif // ENABLE_DEBUG_ELOGIND
}
-
-
-/// Add-On for manager_startup()
-int elogind_manager_startup(Manager *m) {
- int r;
-
- assert(m);
-
- r = sd_event_add_signal(m->event, NULL, SIGINT, elogind_signal_handler, m);
- if (r < 0)
- return log_error_errno(r, "Failed to register SIGINT handler: %m");
-
- r = sd_event_add_signal(m->event, NULL, SIGQUIT, elogind_signal_handler, m);
- if (r < 0)
- return log_error_errno(r, "Failed to register SIGQUIT handler: %m");
-
- r = sd_event_add_signal(m->event, NULL, SIGTERM, elogind_signal_handler, m);
- if (r < 0)
- return log_error_errno(r, "Failed to register SIGTERM handler: %m");
-
- return 0;
-}