manager: send an sd_notify() message informing the container manager when systemd's special UNIX signals become available

From the outside it's difficult to determine whether (and when) the PID1
inside a container supports systemd's more complete set of UNIX process
signals or not. Let's make this easier, and simply send a notification
message when we are ready.
This commit is contained in:
Lennart Poettering
2024-03-12 18:48:28 +01:00
parent e62731f942
commit 6dfa0a9d4c

View File

@@ -594,6 +594,17 @@ static int manager_setup_signals(Manager *m) {
if (r < 0)
return r;
/* Report to supervisor that we now process the above signals. We report this as level "2", to
* indicate that we support more than sysvinit's signals (of course, sysvinit never sent this
* message, but conceptually it makes sense to consider level "1" to be equivalent to sysvinit's
* signal handling). Also, by setting this to "2" people looking for this hopefully won't
* misunderstand this as a boolean concept. Signal level 2 shall refer to the signals PID 1
* understands at the time of release of systemd v256, i.e. including basic SIGRTMIN+18 handling for
* memory pressure and stuff. When more signals are hooked up (or more SIGRTMIN+18 multiplex
* operations added, this level should be increased). */
(void) sd_notify(/* unset_environment= */ false,
"X_SYSTEMD_SIGNALS_LEVEL=2");
if (MANAGER_IS_SYSTEM(m))
return enable_special_signals(m);