]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
manager: reexecute on SIGRTMIN+25, user instances only
authorFranck Bui <fbui@suse.com>
Fri, 23 Jul 2021 09:12:03 +0000 (11:12 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 28 Jul 2021 16:50:30 +0000 (18:50 +0200)
Before this patch, there was no way to request all running user instances for
reexecuting. However this can be useful especially during package updates
otherwise user instances are never updated and keep running a potentially very
old version of the binaries.

Now assuming that we have enough priviledge, it's possible to request
reexecution of all user instances:

  systemctl kill --signal=SIGRTMIN+25 "user@*.service"

Note that this request is obviously asynchronous as it relies on a
signal. Keeping "systemctl kill" as the only interface should be good enough to
make this obvious and that's the reason why another interface, such as
"systemctl --global daemon-reexec" has not been considered.

PID1 already uses SIGTERM for reexecuting hence sending it SIGRTMIN+25 is a
nop.

man/systemd.xml
src/core/manager.c

index fe1719fc1814dcea390c914b72d09e3db5654999..468edfb2d3953e73caa06e428536f83401952f48 100644 (file)
         for --user instances).</para></listitem>
       </varlistentry>
 
+      <varlistentry>
+        <term><constant>SIGRTMIN+25</constant></term>
+
+        <listitem><para>Upon receiving this signal the systemd manager will reexecute itself. This
+        is mostly equivalent to <command>systemctl daemon-reexec</command> except that it will be
+        done asynchronously.</para>
+
+        <para>The systemd system manager treats this signal the same way as
+        <constant>SIGTERM</constant>.</para></listitem>
+      </varlistentry>
+
       <varlistentry>
         <term><constant>SIGRTMIN+26</constant></term>
 
index a3607ea44f6f7b19db99ff398be4adb4b0d1448a..24dfe9fc06b831f2ed7d1cf5fe557a45b9a65cf1 100644 (file)
@@ -578,8 +578,7 @@ static int manager_setup_signals(Manager *m) {
                         SIGRTMIN+22, /* systemd: set log level to LOG_DEBUG */
                         SIGRTMIN+23, /* systemd: set log level to LOG_INFO */
                         SIGRTMIN+24, /* systemd: Immediate exit (--user only) */
-
-                        /* .. one free signal here ... */
+                        SIGRTMIN+25, /* systemd: reexecute manager */
 
                         /* Apparently Linux on hppa had fewer RT signals until v3.18,
                          * SIGRTMAX was SIGRTMIN+25, and then SIGRTMIN was lowered,
@@ -2846,6 +2845,10 @@ static int manager_dispatch_signal_fd(sd_event_source *source, int fd, uint32_t
                         /* This is a nop on init */
                         break;
 
+                case 25:
+                        m->objective = MANAGER_REEXECUTE;
+                        break;
+
                 case 26:
                 case 29: /* compatibility: used to be mapped to LOG_TARGET_SYSLOG_OR_KMSG */
                         manager_restore_original_log_target(m);