summaryrefslogtreecommitdiff
path: root/src/login/elogind.c
diff options
context:
space:
mode:
authorStefan Stefanović <stefanx2ovic@gmail.com>2018-11-04 18:39:03 +0100
committerSven Eden <sven.eden@prydeworx.com>2018-11-10 10:00:27 +0100
commit9f54ff0832237f4040ee9f13679a62425a78a86e (patch)
tree3e83dae73c01884354b0dbc18b66eb6ad47d2cd1 /src/login/elogind.c
parentc35c7b3a589e8f7f99e9fd0e7e853210af5fea9c (diff)
elogind: Try to register any of the signals report errors and return the first error.
Diffstat (limited to 'src/login/elogind.c')
-rw-r--r--src/login/elogind.c44
1 files changed, 27 insertions, 17 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;
+}