HALF ECHO LEARN / REFERENCE COLLECTION

v262.2

man/systemd.exec.xml

343,875 bytesGit mode 100644Download original fileLGPL-2.1-or-later

Git blob: 151cff518a70dc4761d7305857f83b6888834572

Lines 4001–5000 of 5,316

        <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry> – this is
        not recommended since unprivileged userspace can read the kernel command line). </para>
 
        <para>If referencing an <constant>AF_UNIX</constant> stream socket to connect to, the connection will
        originate from an abstract namespace socket, that includes information about the unit and the
        credential ID in its socket name. Use <citerefentry
        project='man-pages'><refentrytitle>getpeername</refentrytitle><manvolnum>2</manvolnum></citerefentry>
        to query this information. The returned socket name is formatted as <constant>NUL</constant>
        <replaceable>RANDOM</replaceable> <literal>/unit/</literal> <replaceable>UNIT</replaceable>
        <literal>/</literal> <replaceable>ID</replaceable>, i.e. a <constant>NUL</constant> byte (as required
        for abstract namespace socket names), followed by a random string (consisting of alphadecimal
        characters), followed by the literal string <literal>/unit/</literal>, followed by the requesting
        unit name, followed by the literal character <literal>/</literal>, followed by the textual credential
        ID requested. Example: <literal>\0adf9d86b6eda275e/unit/foobar.service/credx</literal> in case the
        credential <literal>credx</literal> is requested for a unit <literal>foobar.service</literal>. This
        functionality is useful for using a single listening socket to serve credentials to multiple
        consumers.</para>
 
        <para>For further information see <ulink url="https://systemd.io/CREDENTIALS">System and Service
        Credentials</ulink> documentation.</para>
 
        <xi:include href="version-info.xml" xpointer="v247"/></listitem>
      </varlistentry>
 
      <varlistentry>
        <term><varname>ImportCredential=</varname><replaceable>GLOB</replaceable></term>
 
        <listitem><para>Pass one or more credentials to the unit. Takes a credential name for which we will
        attempt to find a credential that the service manager itself received under the specified name —
        which may be used to propagate credentials from an invoking environment (e.g. a container manager
        that invoked the service manager) into a service. If the credential name is a glob, all credentials
        matching the glob are passed to the unit. Matching credentials are searched for in the system
        credentials, the encrypted system credentials, and under <filename>/etc/credstore/</filename>,
        <filename>/run/credstore/</filename>, <filename>/usr/lib/credstore/</filename>,
        <filename>/run/credstore.encrypted/</filename>, <filename>/etc/credstore.encrypted/</filename>, and
        <filename>/usr/lib/credstore.encrypted/</filename> in that order. When multiple credentials of the
        same name are found, the first one found is used.</para>
 
        <para>The globbing expression implements a restrictive subset of <citerefentry
        project='man-pages'><refentrytitle>glob</refentrytitle><manvolnum>7</manvolnum></citerefentry>: only
        a single trailing <literal>*</literal> wildcard may be specified. Both <literal>?</literal> and
        <literal>[]</literal> wildcards are not permitted, nor are <literal>*</literal> wildcards anywhere
        except at the end of the glob expression.</para>
 
        <para>Optionally, the credential name or glob may be followed by a colon followed by a rename pattern.
        If specified, all credentials matching the credential name or glob are renamed according to the given
        pattern. For example, if <literal>ImportCredential=my.original.cred:my.renamed.cred</literal> is
        specified, the service manager will read the <literal>my.original.cred</literal> credential and make
        it available as the <literal>my.renamed.cred</literal> credential to the service. Similarly, if
        <literal>ImportCredential=my.original.*:my.renamed.</literal> is specified, the service manager will
        read all credentials starting with <literal>my.original.</literal> and make them available as
        <literal>my.renamed.xxx</literal> to the service.</para>
 
        <para>If <varname>ImportCredential=</varname> is specified multiple times and multiple credentials
        end up with the same name after renaming, the first one is kept and later ones are dropped.</para>
 
        <para>When multiple credentials of the same name are found, credentials found by
        <varname>LoadCredential=</varname> and <varname>LoadCredentialEncrypted=</varname> take priority over
        credentials found by <varname>ImportCredential=</varname>.</para>
 
        <para>Note that if decryption or authentication of a credential picked up as result of
        <varname>ImportCredential=</varname> fails it will be skipped gracefully (a warning is generated, but
        the credential will not be made available to the invoked service). This is different for those
        configured via
        <varname>SetCredentialEncrypted=</varname>/<varname>LoadCredentialEncrypted=</varname>, where failed
        decryption/authentication will result in service failure.</para>
 
        <xi:include href="version-info.xml" xpointer="v254"/></listitem>
      </varlistentry>
 
      <varlistentry>
        <term><varname>SetCredential=</varname><replaceable>ID</replaceable>:<replaceable>VALUE</replaceable></term>
        <term><varname>SetCredentialEncrypted=</varname><replaceable>ID</replaceable>:<replaceable>VALUE</replaceable></term>
 
        <listitem><para>The <varname>SetCredential=</varname> setting is similar to
        <varname>LoadCredential=</varname> but accepts a literal value to use as data for the credential,
        instead of a file system path to read the data from. Do not use this option for data that is supposed
        to be secret, as it is accessible to unprivileged processes via IPC. It's only safe to use this for
        user IDs, public key material and similar non-sensitive data. For everything else use
        <varname>LoadCredential=</varname>. In order to embed binary data into the credential data use
        C-style escaping (i.e. <literal>\n</literal> to embed a newline, or <literal>\x00</literal> to embed
        a <constant>NUL</constant> byte).</para>
 
        <para>The <varname>SetCredentialEncrypted=</varname> setting is identical to
        <varname>SetCredential=</varname> but expects an encrypted credential in literal form as value. This
        allows embedding confidential credentials securely directly in unit files. Use
        <citerefentry><refentrytitle>systemd-creds</refentrytitle><manvolnum>1</manvolnum></citerefentry>'
        <option>-p</option> switch to generate suitable <varname>SetCredentialEncrypted=</varname> lines
        directly from plaintext credentials. For further details see
        <varname>LoadCredentialEncrypted=</varname> above.</para>
 
        <para>When multiple credentials of the same name are found, credentials found by
        <varname>LoadCredential=</varname>, <varname>LoadCredentialEncrypted=</varname> and
        <varname>ImportCredential=</varname> take priority over credentials found by
        <varname>SetCredential=</varname>. As such, <varname>SetCredential=</varname> will act as default if
        no credentials are found by any of the former. In this case, not being able to retrieve the credential
        from the path specified in <varname>LoadCredential=</varname> or
        <varname>LoadCredentialEncrypted=</varname> is not considered fatal.</para>
 
        <xi:include href="version-info.xml" xpointer="v247"/></listitem>
      </varlistentry>
    </variablelist>
  </refsect1>
 
  <refsect1>
    <title>System V Compatibility</title>
    <variablelist class='unit-directives'>
 
      <varlistentry>
        <term><varname>UtmpIdentifier=</varname></term>
 
        <listitem><para>Takes a four character identifier string for an <citerefentry
        project='man-pages'><refentrytitle>utmp</refentrytitle><manvolnum>5</manvolnum></citerefentry> and wtmp entry
        for this service. This should only be set for services such as <command>getty</command> implementations (such
        as <citerefentry
        project='die-net'><refentrytitle>agetty</refentrytitle><manvolnum>8</manvolnum></citerefentry>) where utmp/wtmp
        entries must be created and cleared before and after execution, or for services that shall be executed as if
        they were run by a <command>getty</command> process (see below). If the configured string is longer than four
        characters, it is truncated and the terminal four characters are used. This setting interprets %I style string
        replacements. This setting is unset by default, i.e. no utmp/wtmp entries are created or cleaned up for this
        service.</para></listitem>
      </varlistentry>
 
      <varlistentry>
         <term><varname>UtmpMode=</varname></term>
 
         <listitem><para>Takes one of <literal>init</literal>, <literal>login</literal> or <literal>user</literal>. If
         <varname>UtmpIdentifier=</varname> is set, controls which type of <citerefentry
         project='man-pages'><refentrytitle>utmp</refentrytitle><manvolnum>5</manvolnum></citerefentry>/wtmp entries
         for this service are generated. This setting has no effect unless <varname>UtmpIdentifier=</varname> is set
         too. If <literal>init</literal> is set, only an <constant>INIT_PROCESS</constant> entry is generated and the
         invoked process must implement a <command>getty</command>-compatible utmp/wtmp logic. If
         <literal>login</literal> is set, first an <constant>INIT_PROCESS</constant> entry, followed by a
         <constant>LOGIN_PROCESS</constant> entry is generated. In this case, the invoked process must implement a
         <citerefentry
         project='die-net'><refentrytitle>login</refentrytitle><manvolnum>1</manvolnum></citerefentry>-compatible
         utmp/wtmp logic. If <literal>user</literal> is set, first an <constant>INIT_PROCESS</constant> entry, then a
         <constant>LOGIN_PROCESS</constant> entry and finally a <constant>USER_PROCESS</constant> entry is
         generated. In this case, the invoked process may be any process that is suitable to be run as session
         leader. Defaults to <literal>init</literal>.</para>
 
         <xi:include href="version-info.xml" xpointer="v225"/></listitem>
      </varlistentry>
 
    </variablelist>
  </refsect1>
 
  <refsect1>
    <title>Environment Variables in Spawned Processes</title>
 
    <para>Processes started by the service manager are executed with an environment variable block assembled from
    multiple sources. Processes started by the system service manager generally do not inherit environment variables
    set for the service manager itself (but this may be altered via <varname>PassEnvironment=</varname>), but processes
    started by the user service manager instances generally do inherit all environment variables set for the service
    manager itself.</para>
 
    <para>For each invoked process the list of environment variables set is compiled from the following sources:</para>
 
    <itemizedlist>
      <listitem><para>Variables globally configured for the service manager, using the
      <varname>DefaultEnvironment=</varname> setting in
      <citerefentry><refentrytitle>systemd-system.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
      the kernel command line option <varname>systemd.setenv=</varname> understood by
      <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>, or via
      <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>
      <command>set-environment</command> verb.</para></listitem>
 
      <listitem><para>Variables defined by the service manager itself (see the list below).</para></listitem>
 
      <listitem><para>Variables set in the service manager's own environment variable block (subject to
      <varname>PassEnvironment=</varname> for the system service manager).</para></listitem>
 
      <listitem><para>Variables set via <varname>Environment=</varname> in the unit file.</para></listitem>
 
      <listitem><para>Variables read from files specified via <varname>EnvironmentFile=</varname> in the unit
      file.</para></listitem>
 
      <listitem><para>Variables set by any PAM modules in case <varname>PAMName=</varname> is in effect,
      cf. <citerefentry
      project='man-pages'><refentrytitle>pam_env</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
      </para></listitem>
    </itemizedlist>
 
    <para>If the same environment variable is set by multiple of these sources, the later source — according
    to the order of the list above — wins. Note that as the final step all variables listed in
    <varname>UnsetEnvironment=</varname> are removed from the compiled environment variable list, immediately
    before it is passed to the executed process. This unsetting happens after variable expansion in
    the command lines of <varname>ExecStart=</varname> and friends is performed, hence command line
    expansion is not affected by <varname>UnsetEnvironment=</varname>.</para>
 
    <para>The general philosophy is to expose a small curated list of environment variables to processes.
    Services started by the system manager (PID 1) will be started, without additional service-specific
    configuration, with just a few environment variables. The user manager inherits environment variables as
    any other system service, but in addition may receive additional environment variables from PAM, and,
    typically, additional imported variables when the user starts a graphical session. It is recommended to
    keep the environment blocks in both the system and user managers lean. Importing all variables
    inherited by the graphical session or by one of the user shells is strongly discouraged.</para>
 
    <para>Hint: <command>systemd-run -P env</command> and <command>systemd-run --user -P env</command> print
    the effective system and user service environment blocks.</para>
 
    <refsect2>
      <title>Environment Variables Set or Propagated by the Service Manager</title>
 
      <para>The following environment variables are propagated by the service manager or generated internally
      for each invoked process:</para>
 
      <variablelist class='environment-variables'>
        <varlistentry>
          <term><varname>$PATH</varname></term>
 
          <listitem><para>Colon-separated list of directories to use when launching
          executables. <command>systemd</command> uses a fixed value of
          <literal><filename>/usr/local/sbin</filename>:<filename>/usr/local/bin</filename>:<filename>/usr/sbin</filename>:<filename>/usr/bin</filename></literal>
          in the system manager. In case of the user manager, a different path may be configured by the
          distribution. It is recommended to not rely on the order of entries, and have only one program
          with a given name in <varname>$PATH</varname>.</para>
 
          <xi:include href="version-info.xml" xpointer="v208"/></listitem>
        </varlistentry>
 
        <varlistentry>
          <term><varname>$LANG</varname></term>
 
          <listitem><para>Locale. Can be set in <citerefentry
          project='man-pages'><refentrytitle>locale.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>
          or on the kernel command line (see
          <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry> and
          <citerefentry><refentrytitle>kernel-command-line</refentrytitle><manvolnum>7</manvolnum></citerefentry>).
          </para>
 
          <xi:include href="version-info.xml" xpointer="v208"/></listitem>
        </varlistentry>
 
        <varlistentry>
          <term><varname>$USER</varname></term>
          <term><varname>$LOGNAME</varname></term>
          <term><varname>$HOME</varname></term>
          <term><varname>$SHELL</varname></term>
 
          <listitem><para>User name (twice), home directory, and the login shell. <varname>$USER</varname> is
          set unconditionally, while <varname>$HOME</varname>, <varname>$LOGNAME</varname>, and <varname>$SHELL</varname>
          are only set for the units that have <varname>User=</varname> set and <varname>SetLoginEnvironment=</varname>
          unset or set to true. For user services, these variables are typically inherited from the user manager itself. See
          <citerefentry project='die-net'><refentrytitle>passwd</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
          </para>
 
          <xi:include href="version-info.xml" xpointer="v208"/></listitem>
        </varlistentry>
 
        <varlistentry>
          <term><varname>$INVOCATION_ID</varname></term>
 
          <listitem><para>Contains a randomized, unique 128-bit ID identifying each runtime cycle of the unit, formatted
          as 32 character hexadecimal string. A new ID is assigned each time the unit changes from an inactive state into
          an activating or active state, and may be used to identify this specific runtime cycle, in particular in data
          stored offline, such as the journal. The same ID is passed to all processes run as part of the
          unit.</para>
 
          <xi:include href="version-info.xml" xpointer="v232"/></listitem>
        </varlistentry>
 
        <varlistentry>
          <term><varname>$XDG_RUNTIME_DIR</varname></term>
 
          <listitem><para>The directory to use for runtime objects (such as IPC objects) and volatile state. Set for all
          services run by the user <command>systemd</command> instance, as well as any system services that use
          <varname>PAMName=</varname> with a PAM stack that includes <command>pam_systemd</command>. See below and
          <citerefentry><refentrytitle>pam_systemd</refentrytitle><manvolnum>8</manvolnum></citerefentry> for more
          information.</para>
 
          <xi:include href="version-info.xml" xpointer="v208"/></listitem>
        </varlistentry>
 
        <varlistentry>
          <term><varname>$RUNTIME_DIRECTORY</varname></term>
          <term><varname>$STATE_DIRECTORY</varname></term>
          <term><varname>$CACHE_DIRECTORY</varname></term>
          <term><varname>$LOGS_DIRECTORY</varname></term>
          <term><varname>$CONFIGURATION_DIRECTORY</varname></term>
 
          <listitem><para>Absolute paths to the directories defined with
          <varname>RuntimeDirectory=</varname>, <varname>StateDirectory=</varname>,
          <varname>CacheDirectory=</varname>, <varname>LogsDirectory=</varname>, and
          <varname>ConfigurationDirectory=</varname> when those settings are used.</para>
 
          <xi:include href="version-info.xml" xpointer="v244"/>
          </listitem>
        </varlistentry>
 
        <varlistentry>
          <term><varname>$CREDENTIALS_DIRECTORY</varname></term>
 
          <listitem><para>An absolute path to the per-unit directory with credentials configured via
          <varname>ImportCredential=</varname>/<varname>LoadCredential=</varname>/<varname>SetCredential=</varname>.
          The directory is marked read-only and is placed in unswappable memory (if supported and permitted),
          and is only accessible to the UID associated with the unit via <varname>User=</varname> or
          <varname>DynamicUser=</varname> (and the superuser).</para>
 
          <xi:include href="version-info.xml" xpointer="v247"/></listitem>
        </varlistentry>
 
        <varlistentry>
          <term><varname>$TMPDIR</varname></term>
 
          <listitem><para>The environment variable is set to <literal>/tmp</literal> when
          <varname>PrivateTmp=disconnected</varname> specified with <varname>DefaultDependencies=no</varname>
          and without <varname>RootDirectory=/RootImage=</varname> and
          <varname>RequiresMountsFor=/WantsMountsFor=</varname> for <filename>/var/</filename>.
          See explanation for <varname>PrivateTmp=</varname> above.</para>
 
          <xi:include href="version-info.xml" xpointer="v258"/></listitem>
        </varlistentry>
 
        <varlistentry>
          <term><varname>$MAINPID</varname></term>
 
          <listitem><para>The UNIX process ID (PID) of the unit's main process if it is known. This is only
          set for control processes as invoked by <varname>ExecReload=</varname> and similar.</para>
 
          <xi:include href="version-info.xml" xpointer="v209"/></listitem>
        </varlistentry>
 
        <varlistentry>
          <term><varname>$MAINPIDFDID</varname></term>
 
          <listitem><para>The 64bit inode ID of the file descriptor returned by <citerefentry
          project='man-pages'><refentrytitle>pidfd_open</refentrytitle><manvolnum>3</manvolnum></citerefentry>
          for the main process (if supported). This is only set for control processes as invoked by
          <varname>ExecReload=</varname> and similar.</para>
 
          <xi:include href="version-info.xml" xpointer="v258"/></listitem>
        </varlistentry>
 
        <varlistentry>
          <term><varname>$MANAGERPID</varname></term>
 
          <listitem><para>The PID of the per-user <command>systemd</command> service manager instance, set
          for processes spawned by it.</para>
          <xi:include href="version-info.xml" xpointer="v208"/></listitem>
        </varlistentry>
 
        <varlistentry>
          <term><varname>$MANAGERPIDFDID</varname></term>
 
          <listitem><para>The <function>pidfd_open()</function> inode ID (see above) of the per-user
          <command>systemd</command> service manager instance, set for processes spawned by it.</para>
 
          <xi:include href="version-info.xml" xpointer="v258"/></listitem>
        </varlistentry>
 
        <varlistentry>
          <term><varname>$LISTEN_FDS</varname></term>
          <term><varname>$LISTEN_PID</varname></term>
          <term><varname>$LISTEN_PIDFDID</varname></term>
          <term><varname>$LISTEN_FDNAMES</varname></term>
 
          <listitem><para>Information about file descriptors passed to a
          service for socket activation. See
          <citerefentry><refentrytitle>sd_listen_fds</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
          </para>
 
          <xi:include href="version-info.xml" xpointer="v208"/></listitem>
        </varlistentry>
 
        <varlistentry>
          <term><varname>$NOTIFY_SOCKET</varname></term>
 
          <listitem><para>The socket <function>sd_notify()</function> talks to. See
          <citerefentry><refentrytitle>sd_notify</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
          </para>
 
          <xi:include href="version-info.xml" xpointer="v229"/></listitem>
        </varlistentry>
 
        <varlistentry>
          <term><varname>$WATCHDOG_PID</varname></term>
          <term><varname>$WATCHDOG_USEC</varname></term>
 
          <listitem><para>Information about watchdog keep-alive notifications. See
          <citerefentry><refentrytitle>sd_watchdog_enabled</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
          </para>
 
          <xi:include href="version-info.xml" xpointer="v229"/></listitem>
        </varlistentry>
 
        <varlistentry>
          <term><varname>$SYSTEMD_EXEC_PID</varname></term>
 
          <listitem><para>The PID of the unit process (e.g. process invoked by
          <varname>ExecStart=</varname>). The child process can use this information to determine
          whether the process is directly invoked by the service manager or indirectly as a child of
          another process by comparing this value with the current PID (similarly to the scheme used in
          <citerefentry><refentrytitle>sd_listen_fds</refentrytitle><manvolnum>3</manvolnum></citerefentry>
          with <varname>$LISTEN_PID</varname> and <varname>$LISTEN_FDS</varname>).</para>
 
          <xi:include href="version-info.xml" xpointer="v248"/></listitem>
        </varlistentry>
 
        <varlistentry>
          <term><varname>$TERM</varname></term>
 
          <listitem><para>Terminal type, set only for units connected to
          a terminal (<varname>StandardInput=tty</varname>,
          <varname>StandardOutput=tty</varname>, or
          <varname>StandardError=tty</varname>). See
          <citerefentry project='man-pages'><refentrytitle>termcap</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
          </para>
 
          <xi:include href="version-info.xml" xpointer="v209"/></listitem>
        </varlistentry>
 
        <varlistentry>
          <term><varname>$LOG_NAMESPACE</varname></term>
 
          <listitem><para>Contains the name of the selected logging namespace when the
          <varname>LogNamespace=</varname> service setting is used.</para>
 
          <xi:include href="version-info.xml" xpointer="v246"/></listitem>
        </varlistentry>
 
        <varlistentry>
          <term><varname>$JOURNAL_STREAM</varname></term>
 
          <listitem><para>If the standard output or standard error output of the executed processes are connected to the
          journal (for example, by setting <varname>StandardError=journal</varname>) <varname>$JOURNAL_STREAM</varname>
          contains the device and inode numbers of the connection file descriptor, formatted in decimal, separated by a
          colon (<literal>:</literal>). This permits invoked processes to safely detect whether their standard output or
          standard error output are connected to the journal. The device and inode numbers of the file descriptors should
          be compared with the values set in the environment variable to determine whether the process output is still
          connected to the journal. Note that it is generally not sufficient to only check whether
          <varname>$JOURNAL_STREAM</varname> is set at all as services might invoke external processes replacing their
          standard output or standard error output, without unsetting the environment variable.</para>
 
          <para>If both standard output and standard error of the executed processes are connected to the journal via a
          stream socket, this environment variable will contain information about the standard error stream, as that's
          usually the preferred destination for log data. (Note that typically the same stream is used for both standard
          output and standard error, hence very likely the environment variable contains device and inode information
          matching both stream file descriptors.)</para>
 
          <para>This environment variable is primarily useful to allow services to optionally upgrade their used log
          protocol to the native journal protocol (using
          <citerefentry><refentrytitle>sd_journal_print</refentrytitle><manvolnum>3</manvolnum></citerefentry> and other
          functions) if their standard output or standard error output is connected to the journal anyway, thus enabling
          delivery of structured metadata along with logged messages.</para>
 
          <xi:include href="version-info.xml" xpointer="v231"/></listitem>
        </varlistentry>
 
        <varlistentry>
          <term><varname>$SERVICE_RESULT</varname></term>
 
          <listitem><para>Only used for the service unit type. This environment variable is passed to all
          <varname>ExecStop=</varname> and <varname>ExecStopPost=</varname> processes, and encodes the service
          "result". Currently, the following values are defined:</para>
 
          <table>
            <title>Defined <varname>$SERVICE_RESULT</varname> values</title>
            <tgroup cols='2'>
              <colspec colname='result'/>
              <colspec colname='meaning'/>
              <thead>
                <row>
                  <entry>Value</entry>
                  <entry>Meaning</entry>
                </row>
              </thead>
 
              <tbody>
                <row>
                  <entry><literal>success</literal></entry>
                  <entry>The service ran successfully and exited cleanly.</entry>
                </row>
                <row>
                  <entry><literal>protocol</literal></entry>
                  <entry>A protocol violation occurred: the service did not take the steps required by its unit configuration (specifically what is configured in its <varname>Type=</varname> setting).</entry>
                </row>
                <row>
                  <entry><literal>timeout</literal></entry>
                  <entry>One of the steps timed out.</entry>
                </row>
                <row>
                  <entry><literal>exit-code</literal></entry>
                  <entry>Service process exited with a non-zero exit code; see <varname>$EXIT_CODE</varname> below for the actual exit code returned.</entry>
                </row>
                <row>
                  <entry><literal>signal</literal></entry>
                  <entry>A service process was terminated abnormally by a signal, without dumping core. See <varname>$EXIT_CODE</varname> below for the actual signal causing the termination.</entry>
                </row>
                <row>
                  <entry><literal>core-dump</literal></entry>
                  <entry>A service process terminated abnormally with a signal and dumped core. See <varname>$EXIT_CODE</varname> below for the signal causing the termination.</entry>
                </row>
                <row>
                  <entry><literal>watchdog</literal></entry>
                  <entry>Watchdog keep-alive ping was enabled for the service, but the deadline was missed.</entry>
                </row>
                <row>
                  <entry><literal>exec-condition</literal></entry>
                  <entry>Service did not run because <varname>ExecCondition=</varname> failed (that is its command exited with an exit status of 1 through 254 (inclusive)).</entry>
                </row>
                <row>
                  <entry><literal>oom-kill</literal></entry>
                  <entry>A service process was terminated by the Out-Of-Memory (OOM) killer.</entry>
                </row>
                <row>
                  <entry><literal>start-limit-hit</literal></entry>
                  <entry>A start limit was defined for the unit and it was hit, causing the unit to fail to start. See <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>'s <varname>StartLimitIntervalSec=</varname> and <varname>StartLimitBurst=</varname> for details.</entry>
                </row>
                <row>
                  <entry><literal>resources</literal></entry>
                  <entry>A catch-all condition in case a system operation failed.</entry>
                </row>
              </tbody>
            </tgroup>
          </table>
 
          <para>This environment variable is useful to monitor failure or successful termination of a service. Even
          though this variable is available in both <varname>ExecStop=</varname> and <varname>ExecStopPost=</varname>, it
          is usually a better choice to place monitoring tools in the latter, as the former is only invoked for services
          that managed to start up correctly, and the latter covers both services that failed during their start-up and
          those which failed during their runtime.</para>
 
          <xi:include href="version-info.xml" xpointer="v232"/></listitem>
        </varlistentry>
 
        <varlistentry>
          <term><varname>$EXIT_CODE</varname></term>
          <term><varname>$EXIT_STATUS</varname></term>
 
          <listitem><para>Only defined for the service unit type. These environment variables are passed to all
          <varname>ExecStop=</varname>, <varname>ExecStopPost=</varname> processes and contain exit status/code
          information of the main process of the service. For the precise definition of the exit code and status, see
          <citerefentry><refentrytitle>wait</refentrytitle><manvolnum>2</manvolnum></citerefentry>. <varname>$EXIT_CODE</varname>
          is one of <literal>exited</literal>, <literal>killed</literal>,
          <literal>dumped</literal>. <varname>$EXIT_STATUS</varname> contains the numeric exit code formatted as string
          if <varname>$EXIT_CODE</varname> is <literal>exited</literal>, and the signal name in all other cases. Note
          that these environment variables are only set if the service manager succeeded to start and identify the main
          process of the service.</para>
 
          <table>
            <title>Summary of possible service result variable values</title>
            <tgroup cols='3'>
              <colspec colname='result' />
              <colspec colname='code' />
              <colspec colname='status' />
              <thead>
                <row>
                  <entry><varname>$SERVICE_RESULT</varname></entry>
                  <entry><varname>$EXIT_CODE</varname></entry>
                  <entry><varname>$EXIT_STATUS</varname></entry>
                </row>
              </thead>
 
              <tbody>
                <row>
                  <entry morerows="1" valign="top"><literal>success</literal></entry>
                  <entry valign="top"><literal>killed</literal></entry>
                  <entry><literal>HUP</literal>, <literal>INT</literal>, <literal>TERM</literal>, <literal>PIPE</literal></entry>
                </row>
                <row>
                  <entry valign="top"><literal>exited</literal></entry>
                  <entry><literal>0</literal></entry>
                </row>
                <row>
                  <entry morerows="1" valign="top"><literal>protocol</literal></entry>
                  <entry valign="top">not set</entry>
                  <entry>not set</entry>
                </row>
                <row>
                  <entry><literal>exited</literal></entry>
                  <entry><literal>0</literal></entry>
                </row>
                <row>
                  <entry morerows="1" valign="top"><literal>timeout</literal></entry>
                  <entry valign="top"><literal>killed</literal></entry>
                  <entry><literal>TERM</literal>, <literal>KILL</literal></entry>
                </row>
                <row>
                  <entry valign="top"><literal>exited</literal></entry>
                  <entry><literal>0</literal>, <literal>1</literal>, <literal>2</literal>, <literal
                  >3</literal>, …, <literal>255</literal></entry>
                </row>
                <row>
                  <entry valign="top"><literal>exit-code</literal></entry>
                  <entry valign="top"><literal>exited</literal></entry>
                  <entry><literal>1</literal>, <literal>2</literal>, <literal
                  >3</literal>, …, <literal>255</literal></entry>
                </row>
                <row>
                  <entry valign="top"><literal>signal</literal></entry>
                  <entry valign="top"><literal>killed</literal></entry>
                  <entry><literal>HUP</literal>, <literal>INT</literal>, <literal>KILL</literal>, …</entry>
                </row>
                <row>
                  <entry valign="top"><literal>core-dump</literal></entry>
                  <entry valign="top"><literal>dumped</literal></entry>
                  <entry><literal>ABRT</literal>, <literal>SEGV</literal>, <literal>QUIT</literal>, …</entry>
                </row>
                <row>
                  <entry morerows="2" valign="top"><literal>watchdog</literal></entry>
                  <entry><literal>dumped</literal></entry>
                  <entry><literal>ABRT</literal></entry>
                </row>
                <row>
                  <entry><literal>killed</literal></entry>
                  <entry><literal>TERM</literal>, <literal>KILL</literal></entry>
                </row>
                <row>
                  <entry><literal>exited</literal></entry>
                  <entry><literal>0</literal>, <literal>1</literal>, <literal>2</literal>, <literal
                  >3</literal>, …, <literal>255</literal></entry>
                </row>
                <row>
                  <entry valign="top"><literal>exec-condition</literal></entry>
                  <entry><literal>exited</literal></entry>
                  <entry><literal>1</literal>, <literal>2</literal>, <literal>3</literal>, <literal
                  >4</literal>, …, <literal>254</literal></entry>
                </row>
                <row>
                  <entry valign="top"><literal>oom-kill</literal></entry>
                  <entry valign="top"><literal>killed</literal></entry>
                  <entry><literal>TERM</literal>, <literal>KILL</literal></entry>
                </row>
                <row>
                  <entry><literal>start-limit-hit</literal></entry>
                  <entry>not set</entry>
                  <entry>not set</entry>
                </row>
                <row>
                  <entry><literal>resources</literal></entry>
                  <entry>any of the above</entry>
                  <entry>any of the above</entry>
                </row>
                <row>
                  <entry namest="results" nameend="status">Note: the process may be also terminated by a signal not sent by systemd. In particular the process may send an arbitrary signal to itself in a handler for any of the non-maskable signals. Nevertheless, in the <literal>timeout</literal> and <literal>watchdog</literal> rows above only the signals that systemd sends have been included. Moreover, using <varname>SuccessExitStatus=</varname> additional exit statuses may be declared to indicate clean termination, which is not reflected by this table.</entry>
                </row>
              </tbody>
            </tgroup>
          </table>
 
            <xi:include href="version-info.xml" xpointer="v232"/></listitem>
        </varlistentry>
 
        <varlistentry>
          <term><varname>$MONITOR_SERVICE_RESULT</varname></term>
          <term><varname>$MONITOR_EXIT_CODE</varname></term>
          <term><varname>$MONITOR_EXIT_STATUS</varname></term>
          <term><varname>$MONITOR_INVOCATION_ID</varname></term>
          <term><varname>$MONITOR_UNIT</varname></term>
 
          <listitem><para>Only defined for the service unit type. Those environment variables are passed to
          all <varname>ExecStart=</varname> and <varname>ExecStartPre=</varname> processes which run in
          services triggered by <varname>OnFailure=</varname> or <varname>OnSuccess=</varname> dependencies.
          </para>
 
          <para>Variables <varname>$MONITOR_SERVICE_RESULT</varname>, <varname>$MONITOR_EXIT_CODE</varname>
          and <varname>$MONITOR_EXIT_STATUS</varname> take the same values as for
          <varname>ExecStop=</varname> and <varname>ExecStopPost=</varname> processes. Variables
          <varname>$MONITOR_INVOCATION_ID</varname> and <varname>$MONITOR_UNIT</varname> are set to the
          invocation id and unit name of the service which triggered the dependency.</para>
 
          <para>Note that when multiple services specify the same unit as their
          <varname>OnFailure=</varname> or <varname>OnSuccess=</varname> handler, those variables will
          <emphasis>not</emphasis> be passed. Consider using a template handler unit for that case instead:
          <literal>OnFailure=<replaceable>handler</replaceable>@%n.service</literal> for non-templated units,
          or <literal>OnFailure=<replaceable>handler</replaceable>@%p-%i.service</literal> for templated
          units.</para>
 
          <xi:include href="version-info.xml" xpointer="v251"/></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>
 
          <xi:include href="version-info.xml" xpointer="v242"/></listitem>
        </varlistentry>
 
        <varlistentry>
          <term><varname>$REMOTE_ADDR</varname></term>
          <term><varname>$REMOTE_PORT</varname></term>
 
          <listitem><para>If this is a unit started via per-connection socket activation (i.e. via a socket
          unit with <varname>Accept=yes</varname>), these environment variables contain information about the
          remote peer of the socket connection.</para>
 
          <para>For IPv4 and IPv6 connections, <varname>$REMOTE_ADDR</varname> contains the IP address, and
          <varname>$REMOTE_PORT</varname> contains the port number of the remote peer.</para>
 
          <para>For <constant>AF_UNIX</constant> socket connections, <varname>$REMOTE_ADDR</varname> contains
          either the remote socket's file system path starting with a slash (<literal>/</literal>), its
          address in the abstract namespace starting with an at symbol (<literal>@</literal>), or is unset
          in case of an unnamed socket. <varname>$REMOTE_PORT</varname> is not set for <constant>AF_UNIX</constant>
          sockets.</para>
 
          <xi:include href="version-info.xml" xpointer="v220"/></listitem>
        </varlistentry>
 
        <varlistentry>
          <term><varname>$SO_COOKIE</varname></term>
 
          <listitem><para>If this is a unit started via per-connection socket activation (i.e. via a socket
          unit with <varname>Accept=yes</varname>), this environment variable contains the Linux socket
          cookie, formatted as decimal integer. The socket cookie can otherwise be acquired via <citerefentry
          project='man-pages'><refentrytitle>getsockopt</refentrytitle><manvolnum>7</manvolnum></citerefentry>.</para>
 
          <xi:include href="version-info.xml" xpointer="v258"/></listitem>
        </varlistentry>
 
        <varlistentry>
          <term><varname>$TRIGGER_UNIT</varname></term>
          <term><varname>$TRIGGER_PATH</varname></term>
          <term><varname>$TRIGGER_TIMER_REALTIME_USEC</varname></term>
          <term><varname>$TRIGGER_TIMER_MONOTONIC_USEC</varname></term>
 
          <listitem><para>If the unit was activated dynamically (e.g.: a corresponding path unit or timer unit), the
          unit that triggered it and other type-dependent information will be passed via these variables. Note that
          this information is provided in a best-effort way. For example, multiple triggers happening one after
          another will be coalesced and only one will be reported, with no guarantee as to which one it will be.
          Because of this, in most cases this variable will be primarily informational, i.e. useful for debugging
          purposes, is lossy, and should not be relied upon to propagate a comprehensive reason for activation.
          </para>
 
          <xi:include href="version-info.xml" xpointer="v252"/></listitem>
        </varlistentry>
 
        <varlistentry>
          <term><varname>$MEMORY_PRESSURE_WATCH</varname></term>
          <term><varname>$MEMORY_PRESSURE_WRITE</varname></term>
 
          <listitem><para>If memory pressure monitoring is enabled for this service unit, the path to watch
          and the data to write into it. See <ulink url="https://systemd.io/PRESSURE">Resource Pressure
          Handling</ulink> for details about these variables and the service protocol data they
          convey.</para>
 
          <xi:include href="version-info.xml" xpointer="v254"/></listitem>
        </varlistentry>
 
        <varlistentry>
          <term><varname>$CPU_PRESSURE_WATCH</varname></term>
          <term><varname>$CPU_PRESSURE_WRITE</varname></term>
 
          <listitem><para>If CPU pressure monitoring is enabled for this service unit, the path to watch
          and the data to write into it. See <ulink url="https://systemd.io/PRESSURE">Resource Pressure
          Handling</ulink> for details about these variables and the service protocol data they
          convey.</para>
 
          <xi:include href="version-info.xml" xpointer="v261"/></listitem>
        </varlistentry>
 
        <varlistentry>
          <term><varname>$IO_PRESSURE_WATCH</varname></term>
          <term><varname>$IO_PRESSURE_WRITE</varname></term>
 
          <listitem><para>If IO pressure monitoring is enabled for this service unit, the path to watch
          and the data to write into it. See <ulink url="https://systemd.io/PRESSURE">Resource Pressure
          Handling</ulink> for details about these variables and the service protocol data they
          convey.</para>
 
          <xi:include href="version-info.xml" xpointer="v261"/></listitem>
        </varlistentry>
 
        <varlistentry>
          <term><varname>$FDSTORE</varname></term>
 
          <listitem><para>The maximum number of file descriptors that may be stored in the manager for the
          service. This variable is set when the file descriptor store is enabled for the service, i.e.
          <varname>FileDescriptorStoreMax=</varname> is set to a non-zero value (see
          <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>
          for details). Applications may check this environment variable before sending file descriptors to
          the service manager via
          <citerefentry><refentrytitle>sd_pid_notify_with_fds</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
        </para>
 
          <xi:include href="version-info.xml" xpointer="v254"/></listitem>
        </varlistentry>
 
        <varlistentry>
          <term><varname>$DEBUG_INVOCATION</varname></term>
 
          <listitem><para>If <varname>RestartMode=debug</varname> is set, and a previous attempt at starting
          the unit failed, this variable will be passed to the service to indicate that additional logging
          should be enabled at startup. See
          <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>
          for more details.</para>
 
          <xi:include href="version-info.xml" xpointer="v257"/></listitem>
        </varlistentry>
 
      </variablelist>
 
      <para>For system services, when <varname>PAMName=</varname> is enabled and <command>pam_systemd</command> is part
      of the selected PAM stack, additional environment variables defined by systemd may be set for
      services. Specifically, these are <varname>$XDG_SEAT</varname>, <varname>$XDG_VTNR</varname>, see
      <citerefentry><refentrytitle>pam_systemd</refentrytitle><manvolnum>8</manvolnum></citerefentry> for details.</para>
    </refsect2>
 
  </refsect1>
 
  <refsect1>
    <title>Process Exit Codes</title>
 
    <para>When invoking a unit process the service manager possibly fails to apply the execution parameters configured
    with the settings above. In that case the already created service process will exit with a non-zero exit code
    before the configured command line is executed. (Or in other words, the child process possibly exits with these
    error codes, after having been created by the <citerefentry
    project='man-pages'><refentrytitle>fork</refentrytitle><manvolnum>2</manvolnum></citerefentry> system call, but
    before the matching <citerefentry
    project='man-pages'><refentrytitle>execve</refentrytitle><manvolnum>2</manvolnum></citerefentry> system call is
    called.) Specifically, exit codes defined by the C library, by the LSB specification and by the systemd service
    manager itself are used.</para>
 
    <para>The following basic service exit codes are defined by the C library.</para>
 
    <table>
      <title>Basic C library exit codes</title>
      <tgroup cols='3'>
        <thead>
          <row>
            <entry>Exit Code</entry>
            <entry>Symbolic Name</entry>
            <entry>Description</entry>
          </row>
        </thead>
        <tbody>
          <row>
            <entry>0</entry>
            <entry><constant>EXIT_SUCCESS</constant></entry>
            <entry>Generic success code.</entry>
          </row>
          <row>
            <entry>1</entry>
            <entry><constant>EXIT_FAILURE</constant></entry>
            <entry>Generic failure or unspecified error.</entry>
          </row>
        </tbody>
      </tgroup>
    </table>
 
    <para>The following service exit codes are defined by the <ulink
    url="https://refspecs.linuxbase.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-generic/iniscrptact.html">LSB specification</ulink>.
    </para>
 
    <table>
      <title>LSB service exit codes</title>
      <tgroup cols='3'>
        <thead>
          <row>
            <entry>Exit Code</entry>
            <entry>Symbolic Name</entry>
            <entry>Description</entry>
          </row>
        </thead>
        <tbody>
          <row>
            <entry>2</entry>
            <entry><constant>EXIT_INVALIDARGUMENT</constant></entry>
            <entry>Invalid or excess arguments.</entry>
          </row>
          <row>
            <entry>3</entry>
            <entry><constant>EXIT_NOTIMPLEMENTED</constant></entry>
            <entry>Unimplemented feature.</entry>
          </row>
          <row>
            <entry>4</entry>
            <entry><constant>EXIT_NOPERMISSION</constant></entry>
            <entry>The user has insufficient privileges.</entry>
          </row>
          <row>
            <entry>5</entry>
            <entry><constant>EXIT_NOTINSTALLED</constant></entry>
            <entry>The program is not installed.</entry>
          </row>
          <row>
            <entry>6</entry>
            <entry><constant>EXIT_NOTCONFIGURED</constant></entry>
            <entry>The program is not configured.</entry>
          </row>
          <row>
            <entry>7</entry>
            <entry><constant>EXIT_NOTRUNNING</constant></entry>
            <entry>The program is not running.</entry>
          </row>
        </tbody>
      </tgroup>
    </table>
 
    <para>
      The LSB specification suggests that error codes 200 and above are reserved for implementations. Some of them are
      used by the service manager to indicate problems during process invocation:
    </para>
    <table>
      <title>systemd-specific exit codes</title>
      <tgroup cols='3'>
        <thead>
          <row>
            <entry>Exit Code</entry>
            <entry>Symbolic Name</entry>
            <entry>Description</entry>
          </row>
        </thead>
        <tbody>
          <row>
            <entry>200</entry>
            <entry><constant>EXIT_CHDIR</constant></entry>
            <entry>Changing to the requested working directory failed. See <varname>WorkingDirectory=</varname> above.</entry>
          </row>
          <row>
            <entry>201</entry>
            <entry><constant>EXIT_NICE</constant></entry>
            <entry>Failed to set up process scheduling priority (nice level). See <varname>Nice=</varname> above.</entry>
          </row>
          <row>
            <entry>202</entry>
            <entry><constant>EXIT_FDS</constant></entry>
            <entry>Failed to close unwanted file descriptors, or to adjust passed file descriptors.</entry>
          </row>
          <row>
            <entry>203</entry>
            <entry><constant>EXIT_EXEC</constant></entry>
            <entry>The actual process execution failed (specifically, the <citerefentry project='man-pages'><refentrytitle>execve</refentrytitle><manvolnum>2</manvolnum></citerefentry> system call). Most likely this is caused by a missing or non-accessible executable file.</entry>
          </row>
          <row>
            <entry>204</entry>
            <entry><constant>EXIT_MEMORY</constant></entry>
            <entry>Failed to perform an action due to memory shortage.</entry>
          </row>
          <row>
            <entry>205</entry>
            <entry><constant>EXIT_LIMITS</constant></entry>
            <entry>Failed to adjust resource limits. See <varname>LimitCPU=</varname> and related settings above.</entry>
          </row>
          <row>
            <entry>206</entry>
            <entry><constant>EXIT_OOM_ADJUST</constant></entry>
            <entry>Failed to adjust the OOM setting. See <varname>OOMScoreAdjust=</varname> above.</entry>
          </row>
          <row>
            <entry>207</entry>
            <entry><constant>EXIT_SIGNAL_MASK</constant></entry>
            <entry>Failed to set process signal mask.</entry>
          </row>
          <row>
            <entry>208</entry>
            <entry><constant>EXIT_STDIN</constant></entry>
            <entry>Failed to set up standard input. See <varname>StandardInput=</varname> above.</entry>
          </row>
          <row>
            <entry>209</entry>
            <entry><constant>EXIT_STDOUT</constant></entry>
            <entry>Failed to set up standard output. See <varname>StandardOutput=</varname> above.</entry>
          </row>
          <row>
            <entry>210</entry>
            <entry><constant>EXIT_CHROOT</constant></entry>
            <entry>Failed to change root directory (<citerefentry project='man-pages'><refentrytitle>chroot</refentrytitle><manvolnum>2</manvolnum></citerefentry>). See <varname>RootDirectory=</varname>/<varname>RootImage=</varname> above.</entry>
          </row>
          <row>
            <entry>211</entry>
            <entry><constant>EXIT_IOPRIO</constant></entry>
            <entry>Failed to set up IO scheduling priority. See <varname>IOSchedulingClass=</varname>/<varname>IOSchedulingPriority=</varname> above.</entry>
          </row>
          <row>
            <entry>212</entry>
            <entry><constant>EXIT_TIMERSLACK</constant></entry>
            <entry>Failed to set up timer slack. See <varname>TimerSlackNSec=</varname> above.</entry>
          </row>
          <row>
            <entry>213</entry>
            <entry><constant>EXIT_SECUREBITS</constant></entry>
            <entry>Failed to set process secure bits. See <varname>SecureBits=</varname> above.</entry>
          </row>
          <row>
            <entry>214</entry>
            <entry><constant>EXIT_SETSCHEDULER</constant></entry>
            <entry>Failed to set up CPU scheduling. See <varname>CPUSchedulingPolicy=</varname>/<varname>CPUSchedulingPriority=</varname> above.</entry>
          </row>
          <row>
            <entry>215</entry>
            <entry><constant>EXIT_CPUAFFINITY</constant></entry>
            <entry>Failed to set up CPU affinity. See <varname>CPUAffinity=</varname> above.</entry>
          </row>
          <row>
            <entry>216</entry>
            <entry><constant>EXIT_GROUP</constant></entry>
            <entry>Failed to determine or change group credentials. See <varname>Group=</varname>/<varname>SupplementaryGroups=</varname> above.</entry>
          </row>
          <row>
            <entry>217</entry>
            <entry><constant>EXIT_USER</constant></entry>
            <entry>Failed to determine or change user credentials, or to set up user namespacing. See <varname>User=</varname>/<varname>PrivateUsers=</varname> above.</entry>
          </row>