]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/basic/exit-status.h
tree-wide: drop 'This file is part of systemd' blurb
[thirdparty/systemd.git] / src / basic / exit-status.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 #pragma once
3
4 /***
5 Copyright 2010 Lennart Poettering
6 ***/
7
8 #include <stdbool.h>
9
10 #include "hashmap.h"
11 #include "macro.h"
12 #include "set.h"
13
14 /* This defines pretty names for the LSB 'start' verb exit codes. Note that they shouldn't be confused with the LSB
15 * 'status' verb exit codes which are defined very differently. For details see:
16 *
17 * https://refspecs.linuxbase.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-generic/iniscrptact.html
18 */
19
20 enum {
21 /* EXIT_SUCCESS defined by libc */
22 /* EXIT_FAILURE defined by libc */
23 EXIT_INVALIDARGUMENT = 2,
24 EXIT_NOTIMPLEMENTED = 3,
25 EXIT_NOPERMISSION = 4,
26 EXIT_NOTINSTALLED = 5,
27 EXIT_NOTCONFIGURED = 6,
28 EXIT_NOTRUNNING = 7,
29
30 /* BSD's sysexits.h defines a couple EX_xyz exit codes in the range 64 … 78 */
31
32 /* The LSB suggests that error codes >= 200 are "reserved". We use them here under the assumption that they
33 * hence are unused by init scripts. */
34 EXIT_CHDIR = 200,
35 EXIT_NICE,
36 EXIT_FDS,
37 EXIT_EXEC,
38 EXIT_MEMORY,
39 EXIT_LIMITS,
40 EXIT_OOM_ADJUST,
41 EXIT_SIGNAL_MASK,
42 EXIT_STDIN,
43 EXIT_STDOUT,
44 EXIT_CHROOT, /* 210 */
45 EXIT_IOPRIO,
46 EXIT_TIMERSLACK,
47 EXIT_SECUREBITS,
48 EXIT_SETSCHEDULER,
49 EXIT_CPUAFFINITY,
50 EXIT_GROUP,
51 EXIT_USER,
52 EXIT_CAPABILITIES,
53 EXIT_CGROUP,
54 EXIT_SETSID, /* 220 */
55 EXIT_CONFIRM,
56 EXIT_STDERR,
57 _EXIT_RESERVED, /* used to be tcpwrap, don't reuse! */
58 EXIT_PAM,
59 EXIT_NETWORK,
60 EXIT_NAMESPACE,
61 EXIT_NO_NEW_PRIVILEGES,
62 EXIT_SECCOMP,
63 EXIT_SELINUX_CONTEXT,
64 EXIT_PERSONALITY, /* 230 */
65 EXIT_APPARMOR_PROFILE,
66 EXIT_ADDRESS_FAMILIES,
67 EXIT_RUNTIME_DIRECTORY,
68 _EXIT_RESERVED2, /* used to be used by kdbus, don't reuse */
69 EXIT_CHOWN,
70 EXIT_SMACK_PROCESS_LABEL,
71 EXIT_KEYRING,
72 EXIT_STATE_DIRECTORY,
73 EXIT_CACHE_DIRECTORY,
74 EXIT_LOGS_DIRECTORY, /* 240 */
75 EXIT_CONFIGURATION_DIRECTORY,
76 };
77
78 typedef enum ExitStatusLevel {
79 EXIT_STATUS_MINIMAL, /* only cover libc EXIT_STATUS/EXIT_FAILURE */
80 EXIT_STATUS_SYSTEMD, /* cover libc and systemd's own exit codes */
81 EXIT_STATUS_LSB, /* cover libc, systemd's own and LSB exit codes */
82 EXIT_STATUS_FULL, /* cover libc, systemd's own, LSB and BSD (EX_xyz) exit codes */
83 } ExitStatusLevel;
84
85 typedef struct ExitStatusSet {
86 Set *status;
87 Set *signal;
88 } ExitStatusSet;
89
90 const char* exit_status_to_string(int status, ExitStatusLevel level) _const_;
91
92 typedef enum ExitClean {
93 EXIT_CLEAN_DAEMON,
94 EXIT_CLEAN_COMMAND,
95 } ExitClean;
96
97 bool is_clean_exit(int code, int status, ExitClean clean, ExitStatusSet *success_status);
98
99 void exit_status_set_free(ExitStatusSet *x);
100 bool exit_status_set_is_empty(ExitStatusSet *x);
101 bool exit_status_set_test(ExitStatusSet *x, int code, int status);