mirror of
https://github.com/systemd/systemd.git
synced 2025-02-09 13:57:42 +03:00
Merge pull request #9661 from yuwata/add-sigprocmask-to-short-lived-daemons
Add sigprocmask to short lived daemons
This commit is contained in:
commit
4cd44f8e41
@ -15,6 +15,7 @@
|
||||
#include "parse-util.h"
|
||||
#include "path-util.h"
|
||||
#include "selinux-util.h"
|
||||
#include "signal-util.h"
|
||||
#include "strv.h"
|
||||
#include "user-util.h"
|
||||
#include "util.h"
|
||||
@ -670,13 +671,23 @@ int main(int argc, char *argv[]) {
|
||||
goto finish;
|
||||
}
|
||||
|
||||
assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGTERM, SIGINT, -1) >= 0);
|
||||
|
||||
r = sd_event_default(&event);
|
||||
if (r < 0) {
|
||||
log_error_errno(r, "Failed to allocate event loop: %m");
|
||||
goto finish;
|
||||
}
|
||||
|
||||
sd_event_set_watchdog(event, true);
|
||||
(void) sd_event_set_watchdog(event, true);
|
||||
|
||||
r = sd_event_add_signal(event, NULL, SIGINT, NULL, NULL);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = sd_event_add_signal(event, NULL, SIGTERM, NULL, NULL);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = connect_bus(&context, event, &bus);
|
||||
if (r < 0)
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "macro.h"
|
||||
#include "path-util.h"
|
||||
#include "selinux-util.h"
|
||||
#include "signal-util.h"
|
||||
#include "string-util.h"
|
||||
#include "strv.h"
|
||||
#include "user-util.h"
|
||||
@ -738,13 +739,23 @@ int main(int argc, char *argv[]) {
|
||||
goto finish;
|
||||
}
|
||||
|
||||
assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGTERM, SIGINT, -1) >= 0);
|
||||
|
||||
r = sd_event_default(&event);
|
||||
if (r < 0) {
|
||||
log_error_errno(r, "Failed to allocate event loop: %m");
|
||||
goto finish;
|
||||
}
|
||||
|
||||
sd_event_set_watchdog(event, true);
|
||||
(void) sd_event_set_watchdog(event, true);
|
||||
|
||||
r = sd_event_add_signal(event, NULL, SIGINT, NULL, NULL);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = sd_event_add_signal(event, NULL, SIGTERM, NULL, NULL);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = connect_bus(&context, event, &bus);
|
||||
if (r < 0)
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "list.h"
|
||||
#include "path-util.h"
|
||||
#include "selinux-util.h"
|
||||
#include "signal-util.h"
|
||||
#include "string-util.h"
|
||||
#include "strv.h"
|
||||
#include "unit-def.h"
|
||||
@ -909,13 +910,23 @@ int main(int argc, char *argv[]) {
|
||||
goto finish;
|
||||
}
|
||||
|
||||
assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGTERM, SIGINT, -1) >= 0);
|
||||
|
||||
r = sd_event_default(&event);
|
||||
if (r < 0) {
|
||||
log_error_errno(r, "Failed to allocate event loop: %m");
|
||||
goto finish;
|
||||
}
|
||||
|
||||
sd_event_set_watchdog(event, true);
|
||||
(void) sd_event_set_watchdog(event, true);
|
||||
|
||||
r = sd_event_add_signal(event, NULL, SIGINT, NULL, NULL);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = sd_event_add_signal(event, NULL, SIGTERM, NULL, NULL);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = connect_bus(&context, event, &bus);
|
||||
if (r < 0)
|
||||
|
Loading…
x
Reference in New Issue
Block a user