diff options
author | Mike Yuan <me@yhndnzj.com> | 2024-01-09 12:48:39 +0100 |
---|---|---|
committer | Mike Yuan <me@yhndnzj.com> | 2024-01-09 14:57:45 +0100 |
commit | c3ff3175d6f88b3dd61b74243eab5bc1b297176a (patch) | |
tree | aa327908ad33c3ebda584cfa941bb0fcfcf5825d /src/timedate | |
parent | machined,portabled: remove unneeded NOTIFY_STOPPING (diff) | |
download | systemd-c3ff3175d6f88b3dd61b74243eab5bc1b297176a.tar.xz systemd-c3ff3175d6f88b3dd61b74243eab5bc1b297176a.zip |
timedated: modernization
Switch to sd_event_set_signal_exit() and use Type=notify
Diffstat (limited to 'src/timedate')
-rw-r--r-- | src/timedate/timedated.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/timedate/timedated.c b/src/timedate/timedated.c index b4a58fc692..a7dcb83206 100644 --- a/src/timedate/timedated.c +++ b/src/timedate/timedated.c @@ -22,6 +22,7 @@ #include "clock-util.h" #include "conf-files.h" #include "constants.h" +#include "daemon-util.h" #include "fd-util.h" #include "fileio-label.h" #include "fileio.h" @@ -1118,21 +1119,15 @@ static int run(int argc, char *argv[]) { umask(0022); - assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGTERM, SIGINT, -1) >= 0); - r = sd_event_default(&event); if (r < 0) return log_error_errno(r, "Failed to allocate event loop: %m"); (void) sd_event_set_watchdog(event, true); - r = sd_event_add_signal(event, NULL, SIGINT, NULL, NULL); - if (r < 0) - return log_error_errno(r, "Failed to install SIGINT handler: %m"); - - r = sd_event_add_signal(event, NULL, SIGTERM, NULL, NULL); + r = sd_event_set_signal_exit(event, true); if (r < 0) - return log_error_errno(r, "Failed to install SIGTERM handler: %m"); + return log_error_errno(r, "Failed to install SIGINT/SIGTERM handlers: %m"); r = connect_bus(&context, event, &bus); if (r < 0) @@ -1148,6 +1143,10 @@ static int run(int argc, char *argv[]) { if (r < 0) return r; + r = sd_notify(false, NOTIFY_READY); + if (r < 0) + log_warning_errno(r, "Failed to send readiness notification, ignoring: %m"); + r = bus_event_loop_with_idle(event, bus, "org.freedesktop.timedate1", DEFAULT_EXIT_USEC, NULL, NULL); if (r < 0) return log_error_errno(r, "Failed to run event loop: %m"); |