diff options
author | Peter Rajnoha <prajnoha@redhat.com> | 2012-03-14 15:51:51 +0000 |
---|---|---|
committer | Peter Rajnoha <prajnoha@redhat.com> | 2012-03-14 15:51:51 +0000 |
commit | 93945bb6160b333a48b089977436356bfb5948e0 (patch) | |
tree | 8cf8c7cfa967743310ce594785809b3dcbef485f /libdaemon | |
parent | 88bba90e6ef9f8bd3982584d3a91c13c870096dc (diff) | |
download | lvm2-93945bb6160b333a48b089977436356bfb5948e0.tar.gz lvm2-93945bb6160b333a48b089977436356bfb5948e0.tar.xz lvm2-93945bb6160b333a48b089977436356bfb5948e0.zip |
Use SD_ACTIVATION env. var. in systemd units to better detect systemd in use.
LISTEN_PID and LISTEN_FDS environment variables are defined only during systemd
"start" action. But we still need to know whether we're activated during
"reload" action as well - we use the reload action to call "dmeventd -R"/"lvmetad -R"
for statefull daemon restart. We can't use normal "restart" as that is simply
composed of "stop" and "start" and we would lose any state the daemon has.
Diffstat (limited to 'libdaemon')
-rw-r--r-- | libdaemon/server/daemon-server.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/libdaemon/server/daemon-server.c b/libdaemon/server/daemon-server.c index 3cdec348..3e72cd11 100644 --- a/libdaemon/server/daemon-server.c +++ b/libdaemon/server/daemon-server.c @@ -69,6 +69,7 @@ static void _exit_handler(int sig __attribute__((unused))) # define OOM_SCORE_ADJ_MIN (-1000) /* Systemd on-demand activation support */ +# define SD_ACTIVATION_ENV_VAR_NAME "SD_ACTIVATION" # define SD_LISTEN_PID_ENV_VAR_NAME "LISTEN_PID" # define SD_LISTEN_FDS_ENV_VAR_NAME "LISTEN_FDS" # define SD_LISTEN_FDS_START 3 @@ -164,6 +165,10 @@ static int _systemd_handover(struct daemon_state *ds) unsigned long env_pid, env_listen_fds; int r = 0; + /* SD_ACTIVATION must be set! */ + if (!(e = getenv(SD_ACTIVATION_ENV_VAR_NAME)) || strcmp(e, "1")) + goto out; + /* LISTEN_PID must be equal to our PID! */ if (!(e = getenv(SD_LISTEN_PID_ENV_VAR_NAME))) goto out; @@ -188,6 +193,7 @@ static int _systemd_handover(struct daemon_state *ds) ds->socket_fd = SD_FD_SOCKET_SERVER; out: + unsetenv(SD_ACTIVATION_ENV_VAR_NAME); unsetenv(SD_LISTEN_PID_ENV_VAR_NAME); unsetenv(SD_LISTEN_FDS_ENV_VAR_NAME); return r; |