core: export $PIDFILE env var for services, derived from PIDFile=
This commit is contained in:
parent
7ca9289ca2
commit
dcf3c3c3d9
|
@ -2468,6 +2468,18 @@ StandardInputData=SWNrIHNpdHplIGRhIHVuJyBlc3NlIEtsb3BzLAp1ZmYgZWVtYWwga2xvcHAncy
|
|||
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><varname>$PIDFILE</varname></term>
|
||||
|
||||
<listitem><para>The path to the configured PID file, in case the process is forked off on behalf of a
|
||||
service that uses the <varname>PIDFile=</varname> setting, see
|
||||
<citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>
|
||||
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.</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
</variablelist>
|
||||
|
||||
<para>For system services, when <varname>PAMName=</varname> is enabled and <command>pam_systemd</command> is part
|
||||
|
|
|
@ -587,6 +587,7 @@ static char** sanitize_environment(char **l) {
|
|||
"MAINPID",
|
||||
"MANAGERPID",
|
||||
"NOTIFY_SOCKET",
|
||||
"PIDFILE",
|
||||
"REMOTE_ADDR",
|
||||
"REMOTE_PORT",
|
||||
"SERVICE_RESULT",
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue