From: Lennart Poettering Date: Wed, 30 Jan 2019 16:39:09 +0000 (+0100) Subject: core: export $PIDFILE env var for services, derived from PIDFile= X-Git-Tag: v242~375 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=dcf3c3c3d90485f86c89f473cba8fcf7a1127dc9;p=platform%2Fupstream%2Fsystemd.git core: export $PIDFILE env var for services, derived from PIDFile= --- diff --git a/man/systemd.exec.xml b/man/systemd.exec.xml index 0248c3a..d39149b 100644 --- a/man/systemd.exec.xml +++ b/man/systemd.exec.xml @@ -2468,6 +2468,18 @@ StandardInputData=SWNrIHNpdHplIGRhIHVuJyBlc3NlIEtsb3BzLAp1ZmYgZWVtYWwga2xvcHAncy + + + $PIDFILE + + The path to the configured PID file, in case the process is forked off on behalf of a + service that uses the PIDFile= setting, see + systemd.service5 + for details. Service code may use this environment variable to automatically generate a PID file at + the location configured in the unit file. This field is set to an absolute path in the file + system. + + For system services, when PAMName= is enabled and pam_systemd is part diff --git a/src/core/manager.c b/src/core/manager.c index 6086531..fc6f89f 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -587,6 +587,7 @@ static char** sanitize_environment(char **l) { "MAINPID", "MANAGERPID", "NOTIFY_SOCKET", + "PIDFILE", "REMOTE_ADDR", "REMOTE_PORT", "SERVICE_RESULT", diff --git a/src/core/service.c b/src/core/service.c index 324dcf2..fd9a809 100644 --- a/src/core/service.c +++ b/src/core/service.c @@ -1458,7 +1458,7 @@ static int service_spawn( if (r < 0) return r; - our_env = new0(char*, 9); + our_env = new0(char*, 10); if (!our_env) return -ENOMEM; @@ -1474,6 +1474,10 @@ static int service_spawn( if (asprintf(our_env + n_env++, "MANAGERPID="PID_FMT, getpid_cached()) < 0) return -ENOMEM; + if (s->pid_file) + if (asprintf(our_env + n_env++, "PIDFILE=%s", s->pid_file) < 0) + return -ENOMEM; + if (s->socket_fd >= 0) { union sockaddr_union sa; socklen_t salen = sizeof(sa);