chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
minor cleanup
[elogind.git]
/
manager.c
diff --git
a/manager.c
b/manager.c
index a598f1241d52fc003732feeab10772414f68d940..cd97e67da57e5a15e49e17806e320c464d4c7662 100644
(file)
--- a/
manager.c
+++ b/
manager.c
@@
-15,6
+15,7
@@
#include "macro.h"
#include "strv.h"
#include "log.h"
#include "macro.h"
#include "strv.h"
#include "log.h"
+#include "util.h"
Manager* manager_new(void) {
Manager *m;
Manager* manager_new(void) {
Manager *m;
@@
-41,9
+42,14
@@
Manager* manager_new(void) {
if ((m->epoll_fd = epoll_create1(EPOLL_CLOEXEC)) < 0)
goto fail;
if ((m->epoll_fd = epoll_create1(EPOLL_CLOEXEC)) < 0)
goto fail;
+ assert_se(reset_all_signal_handlers() == 0);
+
assert_se(sigemptyset(&mask) == 0);
assert_se(sigaddset(&mask, SIGCHLD) == 0);
assert_se(sigaddset(&mask, SIGINT) == 0);
assert_se(sigemptyset(&mask) == 0);
assert_se(sigaddset(&mask, SIGCHLD) == 0);
assert_se(sigaddset(&mask, SIGINT) == 0);
+ assert_se(sigaddset(&mask, SIGTERM) == 0);
+ assert_se(sigaddset(&mask, SIGWINCH) == 0);
+ assert_se(sigaddset(&mask, SIGHUP) == 0);
assert_se(sigprocmask(SIG_SETMASK, &mask, NULL) == 0);
m->signal_watch.type = WATCH_SIGNAL_FD;
assert_se(sigprocmask(SIG_SETMASK, &mask, NULL) == 0);
m->signal_watch.type = WATCH_SIGNAL_FD;
@@
-1004,8
+1010,12
@@
static int manager_process_signal_fd(Manager *m, bool *quit) {
break;
case SIGINT:
break;
case SIGINT:
+ case SIGTERM:
*quit = true;
return 0;
*quit = true;
return 0;
+
+ default:
+ log_info("Got unhandled signal <%s>.", strsignal(sfsi.ssi_signo));
}
}
}
}
@@
-1074,12
+1084,12
@@
int manager_loop(Manager *m) {
assert(m);
for (;;) {
assert(m);
for (;;) {
- struct epoll_event event
s[32]
;
- int n
, i
;
+ struct epoll_event event;
+ int n;
manager_dispatch_run_queue(m);
manager_dispatch_run_queue(m);
- if ((n = epoll_wait(m->epoll_fd,
events, ELEMENTSOF(events)
, -1)) < 0) {
+ if ((n = epoll_wait(m->epoll_fd,
&event, 1
, -1)) < 0) {
if (errno == -EINTR)
continue;
if (errno == -EINTR)
continue;
@@
-1087,12
+1097,12
@@
int manager_loop(Manager *m) {
return -errno;
}
return -errno;
}
- for (i = 0; i < n; i++) {
- if ((r = process_event(m, events + i, &quit)) < 0)
- return r;
+ assert(n == 1);
- if (quit)
- return 0;
- }
+ if ((r = process_event(m, &event, &quit)) < 0)
+ return r;
+
+ if (quit)
+ return 0;
}
}
}
}