Blame SOURCES/0532-doc-document-service-exit-codes.patch

17b0f1
From a2176ebec2b1ff05b599362af2f8426e1c4fd3ef Mon Sep 17 00:00:00 2001
17b0f1
From: Jan Synacek <jsynacek@redhat.com>
17b0f1
Date: Thu, 26 Jan 2017 13:45:46 +0100
17b0f1
Subject: [PATCH] doc: document service exit codes
17b0f1
17b0f1
(Heavily reworked by Lennart while rebasing)
17b0f1
17b0f1
Fixes: #3545
17b0f1
Replaces: #5159
17b0f1
(cherry picked from commit 91a8f867b6fcdb9b2c4074b571e992e6c7869428)
17b0f1
17b0f1
Resolves: #1178929
17b0f1
---
17b0f1
 man/systemd.exec.xml | 310 +++++++++++++++++++++++++++++++++++++++++++
17b0f1
 1 file changed, 310 insertions(+)
17b0f1
17b0f1
diff --git a/man/systemd.exec.xml b/man/systemd.exec.xml
17b0f1
index 1b14ced788..508146f06c 100644
17b0f1
--- a/man/systemd.exec.xml
17b0f1
+++ b/man/systemd.exec.xml
17b0f1
@@ -1360,6 +1360,316 @@
17b0f1
     cf. <citerefentry project='man-pages'><refentrytitle>pam_env</refentrytitle><manvolnum>8</manvolnum></citerefentry>.</para>
17b0f1
   </refsect1>
17b0f1
 
17b0f1
+  <refsect1>
17b0f1
+    <title>Process exit codes</title>
17b0f1
+
17b0f1
+    <para>When invoking a unit process the service manager possibly fails to apply the execution parameters configured
17b0f1
+    with the settings above. In that case the already created service process will exit with a non-zero exit code
17b0f1
+    before the configured command line is executed. (Or in other words, the child process possibly exits with these
17b0f1
+    error codes, after having been created by the 
17b0f1
+    project='man-pages'><refentrytitle>fork</refentrytitle><manvolnum>2</manvolnum></citerefentry> system call, but
17b0f1
+    before the matching 
17b0f1
+    project='man-pages'><refentrytitle>execve</refentrytitle><manvolnum>2</manvolnum></citerefentry> system call is
17b0f1
+    called.) Specifically, exit codes defined by the C library, by the LSB specification and by the systemd service
17b0f1
+    manager itself are used.</para>
17b0f1
+
17b0f1
+    <para>The following basic service exit codes are defined by the C library.</para>
17b0f1
+
17b0f1
+    
17b0f1
+      <title>Basic C library exit codes</title>
17b0f1
+      <tgroup cols='3'>
17b0f1
+        
17b0f1
+          <row>
17b0f1
+            <entry>Exit Code</entry>
17b0f1
+            <entry>Symbolic Name</entry>
17b0f1
+            <entry>Description</entry>
17b0f1
+          </row>
17b0f1
+        
17b0f1
+        
17b0f1
+          <row>
17b0f1
+            <entry>0</entry>
17b0f1
+            <entry><constant>EXIT_SUCCESS</constant></entry>
17b0f1
+            <entry>Generic success code.</entry>
17b0f1
+          </row>
17b0f1
+          <row>
17b0f1
+            <entry>1</entry>
17b0f1
+            <entry><constant>EXIT_FAILURE</constant></entry>
17b0f1
+            <entry>Generic failure or unspecified error.</entry>
17b0f1
+          </row>
17b0f1
+        
17b0f1
+      </tgroup>
17b0f1
+    
17b0f1
+
17b0f1
+    <para>The following service exit codes are defined by the 
17b0f1
+    url="https://refspecs.linuxbase.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-generic/iniscrptact.html">LSB specification
17b0f1
+    </ulink>.
17b0f1
+    </para>
17b0f1
+
17b0f1
+    
17b0f1
+      <title>LSB service exit codes</title>
17b0f1
+      <tgroup cols='3'>
17b0f1
+        
17b0f1
+          <row>
17b0f1
+            <entry>Exit Code</entry>
17b0f1
+            <entry>Symbolic Name</entry>
17b0f1
+            <entry>Description</entry>
17b0f1
+          </row>
17b0f1
+        
17b0f1
+        
17b0f1
+          <row>
17b0f1
+            <entry>2</entry>
17b0f1
+            <entry><constant>EXIT_INVALIDARGUMENT</constant></entry>
17b0f1
+            <entry>Invalid or excess arguments.</entry>
17b0f1
+          </row>
17b0f1
+          <row>
17b0f1
+            <entry>3</entry>
17b0f1
+            <entry><constant>EXIT_NOTIMPLEMENTED</constant></entry>
17b0f1
+            <entry>Unimplemented feature.</entry>
17b0f1
+          </row>
17b0f1
+          <row>
17b0f1
+            <entry>4</entry>
17b0f1
+            <entry><constant>EXIT_NOPERMISSION</constant></entry>
17b0f1
+            <entry>The user has insufficient privileges.</entry>
17b0f1
+          </row>
17b0f1
+          <row>
17b0f1
+            <entry>5</entry>
17b0f1
+            <entry><constant>EXIT_NOTINSTALLED</constant></entry>
17b0f1
+            <entry>The program is not installed.</entry>
17b0f1
+          </row>
17b0f1
+          <row>
17b0f1
+            <entry>6</entry>
17b0f1
+            <entry><constant>EXIT_NOTCONFIGURED</constant></entry>
17b0f1
+            <entry>The program is not configured.</entry>
17b0f1
+          </row>
17b0f1
+          <row>
17b0f1
+            <entry>7</entry>
17b0f1
+            <entry><constant>EXIT_NOTRUNNING</constant></entry>
17b0f1
+            <entry>The program is not running.</entry>
17b0f1
+          </row>
17b0f1
+        
17b0f1
+      </tgroup>
17b0f1
+    
17b0f1
+
17b0f1
+    <para>
17b0f1
+      The LSB specification suggests that error codes 200 and above are reserved for implementations. Some of them are
17b0f1
+      used by the service manager to indicate problems during process invocation:
17b0f1
+    </para>
17b0f1
+    
17b0f1
+      <title>systemd-specific exit codes</title>
17b0f1
+      <tgroup cols='3'>
17b0f1
+        
17b0f1
+          <row>
17b0f1
+            <entry>Exit Code</entry>
17b0f1
+            <entry>Symbolic Name</entry>
17b0f1
+            <entry>Description</entry>
17b0f1
+          </row>
17b0f1
+        
17b0f1
+        
17b0f1
+          <row>
17b0f1
+            <entry>200</entry>
17b0f1
+            <entry><constant>EXIT_CHDIR</constant></entry>
17b0f1
+            <entry>Changing to the requested working directory failed. See <varname>WorkingDirectory=</varname> above.</entry>
17b0f1
+          </row>
17b0f1
+          <row>
17b0f1
+            <entry>201</entry>
17b0f1
+            <entry><constant>EXIT_NICE</constant></entry>
17b0f1
+            <entry>Failed to set up process scheduling priority (nice level). See <varname>Nice=</varname> above.</entry>
17b0f1
+          </row>
17b0f1
+          <row>
17b0f1
+            <entry>202</entry>
17b0f1
+            <entry><constant>EXIT_FDS</constant></entry>
17b0f1
+            <entry>Failed to close unwanted file descriptors, or to adjust passed file descriptors.</entry>
17b0f1
+          </row>
17b0f1
+          <row>
17b0f1
+            <entry>203</entry>
17b0f1
+            <entry><constant>EXIT_EXEC</constant></entry>
17b0f1
+            <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>
17b0f1
+          </row>
17b0f1
+          <row>
17b0f1
+            <entry>204</entry>
17b0f1
+            <entry><constant>EXIT_MEMORY</constant></entry>
17b0f1
+            <entry>Failed to perform an action due to memory shortage.</entry>
17b0f1
+          </row>
17b0f1
+          <row>
17b0f1
+            <entry>205</entry>
17b0f1
+            <entry><constant>EXIT_LIMITS</constant></entry>
17b0f1
+            <entry>Failed to adjust resoure limits. See <varname>LimitCPU=</varname> and related settings above.</entry>
17b0f1
+          </row>
17b0f1
+          <row>
17b0f1
+            <entry>206</entry>
17b0f1
+            <entry><constant>EXIT_OOM_ADJUST</constant></entry>
17b0f1
+            <entry>Failed to adjust the OOM setting. See <varname>OOMScoreAdjust=</varname> above.</entry>
17b0f1
+          </row>
17b0f1
+          <row>
17b0f1
+            <entry>207</entry>
17b0f1
+            <entry><constant>EXIT_SIGNAL_MASK</constant></entry>
17b0f1
+            <entry>Failed to set process signal mask.</entry>
17b0f1
+          </row>
17b0f1
+          <row>
17b0f1
+            <entry>208</entry>
17b0f1
+            <entry><constant>EXIT_STDIN</constant></entry>
17b0f1
+            <entry>Failed to set up standard input. See <varname>StandardInput=</varname> above.</entry>
17b0f1
+          </row>
17b0f1
+          <row>
17b0f1
+            <entry>209</entry>
17b0f1
+            <entry><constant>EXIT_STDOUT</constant></entry>
17b0f1
+            <entry>Failed to set up standard output. See <varname>StandardOutput=</varname> above.</entry>
17b0f1
+          </row>
17b0f1
+          <row>
17b0f1
+            <entry>210</entry>
17b0f1
+            <entry><constant>EXIT_CHROOT</constant></entry>
17b0f1
+            <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>
17b0f1
+          </row>
17b0f1
+          <row>
17b0f1
+            <entry>211</entry>
17b0f1
+            <entry><constant>EXIT_IOPRIO</constant></entry>
17b0f1
+            <entry>Failed to set up IO scheduling priority. See <varname>IOSchedulingClass=</varname>/<varname>IOSchedulingPriority=</varname> above.</entry>
17b0f1
+          </row>
17b0f1
+          <row>
17b0f1
+            <entry>212</entry>
17b0f1
+            <entry><constant>EXIT_TIMERSLACK</constant></entry>
17b0f1
+            <entry>Failed to set up timer slack. See <varname>TimerSlackNSec=</varname> above.</entry>
17b0f1
+          </row>
17b0f1
+          <row>
17b0f1
+            <entry>213</entry>
17b0f1
+            <entry><constant>EXIT_SECUREBITS</constant></entry>
17b0f1
+            <entry>Failed to set process secure bits. See <varname>SecureBits=</varname> above.</entry>
17b0f1
+          </row>
17b0f1
+          <row>
17b0f1
+            <entry>214</entry>
17b0f1
+            <entry><constant>EXIT_SETSCHEDULER</constant></entry>
17b0f1
+            <entry>Failed to set up CPU scheduling. See <varname>CPUSchedulingPolicy=</varname>/<varname>CPUSchedulingPriority=</varname> above.</entry>
17b0f1
+          </row>
17b0f1
+          <row>
17b0f1
+            <entry>215</entry>
17b0f1
+            <entry><constant>EXIT_CPUAFFINITY</constant></entry>
17b0f1
+            <entry>Failed to set up CPU affinity. See <varname>CPUAffinity=</varname> above.</entry>
17b0f1
+          </row>
17b0f1
+          <row>
17b0f1
+            <entry>216</entry>
17b0f1
+            <entry><constant>EXIT_GROUP</constant></entry>
17b0f1
+            <entry>Failed to determine or change group credentials. See <varname>Group=</varname>/<varname>SupplementaryGroups=</varname> above.</entry>
17b0f1
+          </row>
17b0f1
+          <row>
17b0f1
+            <entry>217</entry>
17b0f1
+            <entry><constant>EXIT_USER</constant></entry>
17b0f1
+            <entry>Failed to determine or change user credentials, or to set up user namespacing. See <varname>User=</varname>/<varname>PrivateUsers=</varname> above.</entry>
17b0f1
+          </row>
17b0f1
+          <row>
17b0f1
+            <entry>218</entry>
17b0f1
+            <entry><constant>EXIT_CAPABILITIES</constant></entry>
17b0f1
+            <entry>Failed to drop capabilities, or apply ambient capabilities. See <varname>CapabilityBoundingSet=</varname>/<varname>AmbientCapabilities=</varname> above.</entry>
17b0f1
+          </row>
17b0f1
+          <row>
17b0f1
+            <entry>219</entry>
17b0f1
+            <entry><constant>EXIT_CGROUP</constant></entry>
17b0f1
+            <entry>Setting up the service control group failed.</entry>
17b0f1
+          </row>
17b0f1
+          <row>
17b0f1
+            <entry>220</entry>
17b0f1
+            <entry><constant>EXIT_SETSID</constant></entry>
17b0f1
+            <entry>Failed to create new process session.</entry>
17b0f1
+          </row>
17b0f1
+          <row>
17b0f1
+            <entry>221</entry>
17b0f1
+            <entry><constant>EXIT_CONFIRM</constant></entry>
17b0f1
+            <entry>Execution has been cancelled by the user. See the <varname>systemd.confirm_spawn=</varname> kernel command line setting on <citerefentry><refentrytitle>kernel-command-line</refentrytitle><manvolnum>7</manvolnum></citerefentry> for details.</entry>
17b0f1
+          </row>
17b0f1
+          <row>
17b0f1
+            <entry>222</entry>
17b0f1
+            <entry><constant>EXIT_STDERR</constant></entry>
17b0f1
+            <entry>Failed to set up standard error output. See <varname>StandardError=</varname> above.</entry>
17b0f1
+          </row>
17b0f1
+          <row>
17b0f1
+            <entry>224</entry>
17b0f1
+            <entry><constant>EXIT_PAM</constant></entry>
17b0f1
+            <entry>Failed to set up PAM session. See <varname>PAMName=</varname> above.</entry>
17b0f1
+          </row>
17b0f1
+          <row>
17b0f1
+            <entry>225</entry>
17b0f1
+            <entry><constant>EXIT_NETWORK</constant></entry>
17b0f1
+            <entry>Failed to set up network namespacing. See <varname>PrivateNetwork=</varname> above.</entry>
17b0f1
+          </row>
17b0f1
+          <row>
17b0f1
+            <entry>226</entry>
17b0f1
+            <entry><constant>EXIT_NAMESPACE</constant></entry>
17b0f1
+            <entry>Failed to set up mount namespacing. See <varname>ReadOnlyPaths=</varname> and related settings above.</entry>
17b0f1
+          </row>
17b0f1
+          <row>
17b0f1
+            <entry>227</entry>
17b0f1
+            <entry><constant>EXIT_NO_NEW_PRIVILEGES</constant></entry>
17b0f1
+            <entry>Failed to disable new priviliges. See <varname>NoNewPrivileges=yes</varname> above.</entry>
17b0f1
+          </row>
17b0f1
+          <row>
17b0f1
+            <entry>228</entry>
17b0f1
+            <entry><constant>EXIT_SECCOMP</constant></entry>
17b0f1
+            <entry>Failed to apply system call filters. See <varname>SystemCallFilter=</varname> and related settings above.</entry>
17b0f1
+          </row>
17b0f1
+          <row>
17b0f1
+            <entry>229</entry>
17b0f1
+            <entry><constant>EXIT_SELINUX_CONTEXT</constant></entry>
17b0f1
+            <entry>Determining or changing SELinux context failed. See <varname>SELinuxContext=</varname> above.</entry>
17b0f1
+          </row>
17b0f1
+          <row>
17b0f1
+            <entry>230</entry>
17b0f1
+            <entry><constant>EXIT_PERSONALITY</constant></entry>
17b0f1
+            <entry>Failed to set up a execution domain (personality). See <varname>Personality=</varname> above.</entry>
17b0f1
+          </row>
17b0f1
+          <row>
17b0f1
+            <entry>231</entry>
17b0f1
+            <entry><constant>EXIT_APPARMOR_PROFILE</constant></entry>
17b0f1
+            <entry>Failed to prepare changing AppArmor profile. See <varname>AppArmorProfile=</varname> above.</entry>
17b0f1
+          </row>
17b0f1
+          <row>
17b0f1
+            <entry>232</entry>
17b0f1
+            <entry><constant>EXIT_ADDRESS_FAMILIES</constant></entry>
17b0f1
+            <entry>Failed to restrict address families. See <varname>RestrictAddressFamilies=</varname> above.</entry>
17b0f1
+          </row>
17b0f1
+          <row>
17b0f1
+            <entry>233</entry>
17b0f1
+            <entry><constant>EXIT_RUNTIME_DIRECTORY</constant></entry>
17b0f1
+            <entry>Setting up runtime directory failed. See <varname>RuntimeDirectory=</varname> and related settings above.</entry>
17b0f1
+          </row>
17b0f1
+          <row>
17b0f1
+            <entry>235</entry>
17b0f1
+            <entry><constant>EXIT_CHOWN</constant></entry>
17b0f1
+            <entry>Failed to adjust socket ownership. Used for socket units only.</entry>
17b0f1
+          </row>
17b0f1
+          <row>
17b0f1
+            <entry>236</entry>
17b0f1
+            <entry><constant>EXIT_SMACK_PROCESS_LABEL</constant></entry>
17b0f1
+            <entry>Failed to set SMACK label. See <varname>SmackProcessLabel=</varname> above.</entry>
17b0f1
+          </row>
17b0f1
+          <row>
17b0f1
+            <entry>237</entry>
17b0f1
+            <entry><constant>EXIT_KEYRING</constant></entry>
17b0f1
+            <entry>Failed to set up kernel keyring.</entry>
17b0f1
+          </row>
17b0f1
+          <row>
17b0f1
+            <entry>238</entry>
17b0f1
+            <entry><constant>EXIT_STATE_DIRECTORY</constant></entry>
17b0f1
+            <entry>Failed to set up a the unit's state directory. See <varname>StateDirectory=</varname> above.</entry>
17b0f1
+          </row>
17b0f1
+          <row>
17b0f1
+            <entry>239</entry>
17b0f1
+            <entry><constant>EXIT_CACHE_DIRECTORY</constant></entry>
17b0f1
+            <entry>Failed to set up a the unit's cache directory. See <varname>CacheDirectory=</varname> above.</entry>
17b0f1
+          </row>
17b0f1
+          <row>
17b0f1
+            <entry>240</entry>
17b0f1
+            <entry><constant>EXIT_LOGS_DIRECTORY</constant></entry>
17b0f1
+            <entry>Failed to set up a the unit's logging directory. See <varname>LogsDirectory=</varname> above.</entry>
17b0f1
+          </row>
17b0f1
+          <row>
17b0f1
+            <entry>241</entry>
17b0f1
+            <entry><constant>EXIT_CONFIGURATION_DIRECTORY</constant></entry>
17b0f1
+            <entry>Failed to set up a the unit's configuration directory. See <varname>ConfigurationDirectory=</varname> above.</entry>
17b0f1
+          </row>
17b0f1
+        
17b0f1
+      </tgroup>
17b0f1
+    
17b0f1
+  </refsect1>
17b0f1
+
17b0f1
   <refsect1>
17b0f1
       <title>See Also</title>
17b0f1
       <para>