]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/basic/exit-status.h
Add SPDX license identifiers to source files under the LGPL
[thirdparty/systemd.git] / src / basic / exit-status.h
CommitLineData
53e1b683 1/* SPDX-License-Identifier: LGPL-2.1+ */
c2f1db8f 2#pragma once
1afbdcb0
LP
3
4/***
5 This file is part of systemd.
6
7 Copyright 2010 Lennart Poettering
8
9 systemd is free software; you can redistribute it and/or modify it
5430f7f2
LP
10 under the terms of the GNU Lesser General Public License as published by
11 the Free Software Foundation; either version 2.1 of the License, or
1afbdcb0
LP
12 (at your option) any later version.
13
14 systemd is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5430f7f2 17 Lesser General Public License for more details.
1afbdcb0 18
5430f7f2 19 You should have received a copy of the GNU Lesser General Public License
1afbdcb0
LP
20 along with systemd; If not, see <http://www.gnu.org/licenses/>.
21***/
22
9a57c629 23#include <stdbool.h>
4d7213b2 24
11c3a366
TA
25#include "hashmap.h"
26#include "macro.h"
93cc7779 27#include "set.h"
4d7213b2 28
c9d81ae8
LP
29/* This defines pretty names for the LSB 'start' verb exit codes. Note that they shouldn't be confused with the LSB
30 * 'status' verb exit codes which are defined very differently. For details see:
31 *
32 * https://refspecs.linuxbase.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-generic/iniscrptact.html
33 */
34
65e3fd83 35enum {
1afbdcb0
LP
36 /* EXIT_SUCCESS defined by libc */
37 /* EXIT_FAILURE defined by libc */
38 EXIT_INVALIDARGUMENT = 2,
39 EXIT_NOTIMPLEMENTED = 3,
40 EXIT_NOPERMISSION = 4,
41 EXIT_NOTINSTALLED = 5,
42 EXIT_NOTCONFIGURED = 6,
43 EXIT_NOTRUNNING = 7,
44
45 /* The LSB suggests that error codes >= 200 are "reserved". We
46 * use them here under the assumption that they hence are
c9d81ae8 47 * unused by init scripts. */
1afbdcb0
LP
48
49 EXIT_CHDIR = 200,
50 EXIT_NICE,
51 EXIT_FDS,
52 EXIT_EXEC,
53 EXIT_MEMORY,
54 EXIT_LIMITS,
55 EXIT_OOM_ADJUST,
56 EXIT_SIGNAL_MASK,
57 EXIT_STDIN,
58 EXIT_STDOUT,
59 EXIT_CHROOT, /* 210 */
60 EXIT_IOPRIO,
61 EXIT_TIMERSLACK,
62 EXIT_SECUREBITS,
63 EXIT_SETSCHEDULER,
64 EXIT_CPUAFFINITY,
65 EXIT_GROUP,
66 EXIT_USER,
67 EXIT_CAPABILITIES,
68 EXIT_CGROUP,
69 EXIT_SETSID, /* 220 */
70 EXIT_CONFIRM,
71 EXIT_STDERR,
7f8aa671 72 _EXIT_RESERVED, /* used to be tcpwrap, don't reuse! */
ff01d048 73 EXIT_PAM,
4c2630eb 74 EXIT_NETWORK,
8351ceae
LP
75 EXIT_NAMESPACE,
76 EXIT_NO_NEW_PRIVILEGES,
7b52a628 77 EXIT_SECCOMP,
ac45f971 78 EXIT_SELINUX_CONTEXT,
eef65bf3 79 EXIT_PERSONALITY, /* 230 */
4298d0b5
LP
80 EXIT_APPARMOR_PROFILE,
81 EXIT_ADDRESS_FAMILIES,
3900e5fd 82 EXIT_RUNTIME_DIRECTORY,
be7e509e 83 _EXIT_RESERVED2, /* used to be used by kdbus, don't reuse */
3900e5fd 84 EXIT_CHOWN,
2ca620c4 85 EXIT_SMACK_PROCESS_LABEL,
74dd6b51 86 EXIT_KEYRING,
3536f49e
YW
87 EXIT_STATE_DIRECTORY,
88 EXIT_CACHE_DIRECTORY,
89 EXIT_LOGS_DIRECTORY, /* 240 */
90 EXIT_CONFIGURATION_DIRECTORY,
65e3fd83 91};
1afbdcb0
LP
92
93typedef enum ExitStatusLevel {
c9d81ae8
LP
94 EXIT_STATUS_MINIMAL, /* only cover libc EXIT_STATUS/EXIT_FAILURE */
95 EXIT_STATUS_SYSTEMD, /* cover libc and systemd's own exit codes */
96 EXIT_STATUS_LSB, /* cover libc, systemd's own and LSB exit codes */
1afbdcb0
LP
97 EXIT_STATUS_FULL = EXIT_STATUS_LSB
98} ExitStatusLevel;
99
96342de6 100typedef struct ExitStatusSet {
3e2d435b 101 Set *status;
96342de6
LN
102 Set *signal;
103} ExitStatusSet;
104
65e3fd83 105const char* exit_status_to_string(int status, ExitStatusLevel level) _const_;
1afbdcb0 106
1f0958f6
LP
107typedef enum ExitClean {
108 EXIT_CLEAN_DAEMON,
109 EXIT_CLEAN_COMMAND,
110} ExitClean;
111
112bool is_clean_exit(int code, int status, ExitClean clean, ExitStatusSet *success_status);
37520c1b
LP
113
114void exit_status_set_free(ExitStatusSet *x);
55ebf98c 115bool exit_status_set_is_empty(ExitStatusSet *x);
597466f4 116bool exit_status_set_test(ExitStatusSet *x, int code, int status);