]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
localed: modernization 30849/head
authorMike Yuan <me@yhndnzj.com>
Tue, 9 Jan 2024 11:59:02 +0000 (19:59 +0800)
committerMike Yuan <me@yhndnzj.com>
Tue, 9 Jan 2024 13:57:46 +0000 (21:57 +0800)
src/locale/localed.c
units/systemd-localed.service.in

index 8ce8c0d08fc5eff6003fcbe78555ee870c6d0125..cf88da37ad9f7c798c5ee117d40ef34d0a939e57 100644 (file)
@@ -15,6 +15,7 @@
 #include "bus-polkit.h"
 #include "bus-unit-util.h"
 #include "constants.h"
+#include "daemon-util.h"
 #include "kbd-util.h"
 #include "localed-util.h"
 #include "macro.h"
@@ -647,26 +648,24 @@ static int run(int argc, char *argv[]) {
         if (r < 0)
                 return r;
 
-        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)
                 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.locale1", DEFAULT_EXIT_USEC, NULL, NULL);
         if (r < 0)
                 return log_error_errno(r, "Failed to run event loop: %m");
index 19383ae42397cd8a9569cc1dfa377e8c52375c17..4de89aa8ddd9563afc0611a0797d4e7008966fd2 100644 (file)
@@ -15,6 +15,7 @@ Documentation=man:vconsole.conf(5)
 Documentation=man:org.freedesktop.locale1(5)
 
 [Service]
+Type=notify
 BusName=org.freedesktop.locale1
 CapabilityBoundingSet=
 ExecStart={{LIBEXECDIR}}/systemd-localed