]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/shared/exit-status.h
Merge pull request #11827 from keszybz/pkgconfig-variables
[thirdparty/systemd.git] / src / shared / exit-status.h
CommitLineData
53e1b683 1/* SPDX-License-Identifier: LGPL-2.1+ */
c2f1db8f 2#pragma once
1afbdcb0 3
9a57c629 4#include <stdbool.h>
4d7213b2 5
11c3a366
TA
6#include "hashmap.h"
7#include "macro.h"
93cc7779 8#include "set.h"
4d7213b2 9
c9d81ae8
LP
10/* This defines pretty names for the LSB 'start' verb exit codes. Note that they shouldn't be confused with the LSB
11 * 'status' verb exit codes which are defined very differently. For details see:
12 *
13 * https://refspecs.linuxbase.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-generic/iniscrptact.html
14 */
15
65e3fd83 16enum {
1afbdcb0
LP
17 /* EXIT_SUCCESS defined by libc */
18 /* EXIT_FAILURE defined by libc */
19 EXIT_INVALIDARGUMENT = 2,
20 EXIT_NOTIMPLEMENTED = 3,
21 EXIT_NOPERMISSION = 4,
22 EXIT_NOTINSTALLED = 5,
23 EXIT_NOTCONFIGURED = 6,
24 EXIT_NOTRUNNING = 7,
25
0a233ba1 26 /* BSD's sysexits.h defines a couple EX_xyz exit codes in the range 64 … 78 */
1afbdcb0 27
0a233ba1
LP
28 /* The LSB suggests that error codes >= 200 are "reserved". We use them here under the assumption that they
29 * hence are unused by init scripts. */
1afbdcb0
LP
30 EXIT_CHDIR = 200,
31 EXIT_NICE,
32 EXIT_FDS,
33 EXIT_EXEC,
34 EXIT_MEMORY,
35 EXIT_LIMITS,
36 EXIT_OOM_ADJUST,
37 EXIT_SIGNAL_MASK,
38 EXIT_STDIN,
39 EXIT_STDOUT,
40 EXIT_CHROOT, /* 210 */
41 EXIT_IOPRIO,
42 EXIT_TIMERSLACK,
43 EXIT_SECUREBITS,
44 EXIT_SETSCHEDULER,
45 EXIT_CPUAFFINITY,
46 EXIT_GROUP,
47 EXIT_USER,
48 EXIT_CAPABILITIES,
49 EXIT_CGROUP,
50 EXIT_SETSID, /* 220 */
51 EXIT_CONFIRM,
52 EXIT_STDERR,
7f8aa671 53 _EXIT_RESERVED, /* used to be tcpwrap, don't reuse! */
ff01d048 54 EXIT_PAM,
4c2630eb 55 EXIT_NETWORK,
8351ceae
LP
56 EXIT_NAMESPACE,
57 EXIT_NO_NEW_PRIVILEGES,
7b52a628 58 EXIT_SECCOMP,
ac45f971 59 EXIT_SELINUX_CONTEXT,
eef65bf3 60 EXIT_PERSONALITY, /* 230 */
4298d0b5
LP
61 EXIT_APPARMOR_PROFILE,
62 EXIT_ADDRESS_FAMILIES,
3900e5fd 63 EXIT_RUNTIME_DIRECTORY,
be7e509e 64 _EXIT_RESERVED2, /* used to be used by kdbus, don't reuse */
3900e5fd 65 EXIT_CHOWN,
2ca620c4 66 EXIT_SMACK_PROCESS_LABEL,
74dd6b51 67 EXIT_KEYRING,
3536f49e
YW
68 EXIT_STATE_DIRECTORY,
69 EXIT_CACHE_DIRECTORY,
70 EXIT_LOGS_DIRECTORY, /* 240 */
71 EXIT_CONFIGURATION_DIRECTORY,
3584d3ca
LP
72
73 EXIT_EXCEPTION = 255, /* Whenever we want to propagate an abnormal/signal exit, in line with bash */
65e3fd83 74};
1afbdcb0
LP
75
76typedef enum ExitStatusLevel {
c9d81ae8
LP
77 EXIT_STATUS_MINIMAL, /* only cover libc EXIT_STATUS/EXIT_FAILURE */
78 EXIT_STATUS_SYSTEMD, /* cover libc and systemd's own exit codes */
79 EXIT_STATUS_LSB, /* cover libc, systemd's own and LSB exit codes */
0a233ba1 80 EXIT_STATUS_FULL, /* cover libc, systemd's own, LSB and BSD (EX_xyz) exit codes */
1afbdcb0
LP
81} ExitStatusLevel;
82
96342de6 83typedef struct ExitStatusSet {
3e2d435b 84 Set *status;
96342de6
LN
85 Set *signal;
86} ExitStatusSet;
87
65e3fd83 88const char* exit_status_to_string(int status, ExitStatusLevel level) _const_;
1afbdcb0 89
1f0958f6
LP
90typedef enum ExitClean {
91 EXIT_CLEAN_DAEMON,
92 EXIT_CLEAN_COMMAND,
93} ExitClean;
94
95bool is_clean_exit(int code, int status, ExitClean clean, ExitStatusSet *success_status);
37520c1b
LP
96
97void exit_status_set_free(ExitStatusSet *x);
55ebf98c 98bool exit_status_set_is_empty(ExitStatusSet *x);
597466f4 99bool exit_status_set_test(ExitStatusSet *x, int code, int status);