summaryrefslogtreecommitdiff
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
parent45f85d95ed11f4e85ee8519f8bedfb75d9e5bc73 (diff)
elogind: Use SIG_BLOCK before signal handler registration.
-rw-r--r--src/login/elogind.c38
-rw-r--r--src/login/elogind.h4
-rw-r--r--src/login/logind.c5
3 files changed, 18 insertions, 29 deletions
diff --git a/src/login/elogind.c b/src/login/elogind.c
index d5cf633..58040f3 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;
-}
diff --git a/src/login/elogind.h b/src/login/elogind.h
index 60b9f80..a5743a1 100644
--- a/src/login/elogind.h
+++ b/src/login/elogind.h
@@ -41,8 +41,4 @@ int elogind_manager_new(Manager* m);
/// Add-On for manager_reset_config()
void elogind_manager_reset_config(Manager* m);
-/// Add-On for manager_startup()
-int elogind_manager_startup(Manager *m);
-
-
#endif // ELOGIND_SRC_LOGIN_ELOGIN_H_INCLUDED
diff --git a/src/login/logind.c b/src/login/logind.c
index fcb70e1..d9b777f 100644
--- a/src/login/logind.c
+++ b/src/login/logind.c
@@ -89,6 +89,7 @@ static int manager_new(Manager **ret) {
if (r < 0)
return r;
+#if 0 /// elogind uses its own signal handler, installed at elogind_manager_new()
r = sd_event_add_signal(m->event, NULL, SIGINT, NULL, NULL);
if (r < 0)
return r;
@@ -96,6 +97,7 @@ static int manager_new(Manager **ret) {
r = sd_event_add_signal(m->event, NULL, SIGTERM, NULL, NULL);
if (r < 0)
return r;
+#endif // 0
(void) sd_event_set_watchdog(m->event, true);
@@ -1151,9 +1153,6 @@ static int manager_startup(Manager *m) {
if (r < 0)
return log_error_errno(r, "Failed to register SIGHUP handler: %m");
-#if 1 /// elogind needs some extra preparations before connecting...
- elogind_manager_startup(m);
-#endif // 1
/* Connect to utmp */
manager_connect_utmp(m);