summaryrefslogtreecommitdiff
path: root/src/login
diff options
context:
space:
mode:
Diffstat (limited to 'src/login')
-rw-r--r--src/login/elogind.c44
-rw-r--r--src/login/elogind.h3
-rw-r--r--src/login/logind.c12
3 files changed, 41 insertions, 18 deletions
diff --git a/src/login/elogind.c b/src/login/elogind.c
index 58040f3..edcf312 100644
--- a/src/login/elogind.c
+++ b/src/login/elogind.c
@@ -372,7 +372,7 @@ void elogind_manager_free(Manager* m) {
/// Add-On for manager_new()
int elogind_manager_new(Manager* m) {
- int r = 0;
+ int r = 0, e = 0;
m->cgroups_agent_fd = -1;
m->pin_cgroupfs_fd = -1;
@@ -398,22 +398,6 @@ 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;
}
@@ -469,3 +453,29 @@ 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, e = 0;
+
+ /* Install our signal handler */
+ r = sd_event_add_signal(m->event, NULL, SIGINT, elogind_signal_handler, m);
+ if (r < 0) {
+ if (e == 0) e = r;
+ 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) {
+ if (e == 0) e = r;
+ 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) {
+ if (e == 0) e = r;
+ log_error_errno(r, "Failed to register SIGTERM handler: %m");
+ }
+
+ return e;
+}
diff --git a/src/login/elogind.h b/src/login/elogind.h
index a5743a1..37bcb1e 100644
--- a/src/login/elogind.h
+++ b/src/login/elogind.h
@@ -41,4 +41,7 @@ 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 d9b777f..558733b 100644
--- a/src/login/logind.c
+++ b/src/login/logind.c
@@ -89,7 +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()
+#if 0 /// elogind uses its own signal handler, installed at elogind_manager_startup()
r = sd_event_add_signal(m->event, NULL, SIGINT, NULL, NULL);
if (r < 0)
return r;
@@ -1153,6 +1153,12 @@ static int manager_startup(Manager *m) {
if (r < 0)
return log_error_errno(r, "Failed to register SIGHUP handler: %m");
+#if 1 /// install elogind specific signal handlers
+ r = elogind_manager_startup(m);
+ if (r < 0)
+ return log_error_errno(r, "Failed to register elogind signal handlers: %m");
+#endif // 1
+
/* Connect to utmp */
manager_connect_utmp(m);
@@ -1326,7 +1332,11 @@ int main(int argc, char *argv[]) {
return log_error_errno(r, "Failed to create /run/systemd/machines : %m");
#endif // 0
+#if 0 /// elogind also blocks SIGQUIT, and installs a signal handler for it
assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGHUP, SIGTERM, SIGINT, -1) >= 0);
+#else
+ assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGHUP, SIGTERM, SIGINT, SIGQUIT, -1) >= 0);
+#endif // 0
r = manager_new(&m);
if (r < 0) {