diff options
author | Lennart Poettering <lennart@poettering.net> | 2024-11-14 23:16:19 +0100 |
---|---|---|
committer | Luca Boccassi <luca.boccassi@gmail.com> | 2024-11-15 14:34:06 +0100 |
commit | 4b20ae9a0e914e61d6bac095e5fc9664510ac03e (patch) | |
tree | 5809ea7af3682a499d12f1bded1e2443ac3025c4 /src/core | |
parent | Add proper dependencies to ukify target (diff) | |
download | systemd-4b20ae9a0e914e61d6bac095e5fc9664510ac03e.tar.xz systemd-4b20ae9a0e914e61d6bac095e5fc9664510ac03e.zip |
pid1: make clear that $WATCHDOG_USEC is set for the shutdown binary, noone else
We use the $WATCHDOG_USEC variable for two very closely uses: as part of
the sd_watchdog_enabled() protocol for implementing service watchdogs.
And as part of the protocol between the service manager and
systemd-shutdown across the PID 1 execve() transition during shutdown.
Apparently some exitrds tools got confused by the latter use. Let's
address that by setting $WATCHDOG_PID to 1, in accordance to the
sd_watchdog_enabled() protocol to make clear this is only intended for
PID 1 and nothing else.
Replaces: #35135
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/main.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/core/main.c b/src/core/main.c index 38216fa7a6..172742c769 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -1689,6 +1689,11 @@ static int become_shutdown(int objective, int retval) { /* Tell the binary how often to ping, ignore failure */ (void) strv_extendf(&env_block, "WATCHDOG_USEC="USEC_FMT, watchdog_timer); + /* Make sure that tools that look for $WATCHDOG_USEC (and might get started by the exitrd) don't get + * confused by the variable, because the sd_watchdog_enabled() protocol uses the same variable for + * the same purposes. */ + (void) strv_extendf(&env_block, "WATCHDOG_PID=" PID_FMT, getpid_cached()); + if (arg_watchdog_device) (void) strv_extendf(&env_block, "WATCHDOG_DEVICE=%s", arg_watchdog_device); |