]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/basic/exit-status.h
1e10419f8b4f4a058ecb23be593b7362210a3368
[thirdparty/systemd.git] / src / basic / exit-status.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 #pragma once
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
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
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
17 Lesser General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public License
20 along with systemd; If not, see <http://www.gnu.org/licenses/>.
21 ***/
22
23 #include <stdbool.h>
24
25 #include "hashmap.h"
26 #include "macro.h"
27 #include "set.h"
28
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
35 enum {
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
47 * unused by init scripts. */
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,
72 _EXIT_RESERVED, /* used to be tcpwrap, don't reuse! */
73 EXIT_PAM,
74 EXIT_NETWORK,
75 EXIT_NAMESPACE,
76 EXIT_NO_NEW_PRIVILEGES,
77 EXIT_SECCOMP,
78 EXIT_SELINUX_CONTEXT,
79 EXIT_PERSONALITY, /* 230 */
80 EXIT_APPARMOR_PROFILE,
81 EXIT_ADDRESS_FAMILIES,
82 EXIT_RUNTIME_DIRECTORY,
83 _EXIT_RESERVED2, /* used to be used by kdbus, don't reuse */
84 EXIT_CHOWN,
85 EXIT_SMACK_PROCESS_LABEL,
86 EXIT_KEYRING,
87 EXIT_STATE_DIRECTORY,
88 EXIT_CACHE_DIRECTORY,
89 EXIT_LOGS_DIRECTORY, /* 240 */
90 EXIT_CONFIGURATION_DIRECTORY,
91 };
92
93 typedef enum ExitStatusLevel {
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 */
97 EXIT_STATUS_FULL = EXIT_STATUS_LSB
98 } ExitStatusLevel;
99
100 typedef struct ExitStatusSet {
101 Set *status;
102 Set *signal;
103 } ExitStatusSet;
104
105 const char* exit_status_to_string(int status, ExitStatusLevel level) _const_;
106
107 typedef enum ExitClean {
108 EXIT_CLEAN_DAEMON,
109 EXIT_CLEAN_COMMAND,
110 } ExitClean;
111
112 bool is_clean_exit(int code, int status, ExitClean clean, ExitStatusSet *success_status);
113
114 void exit_status_set_free(ExitStatusSet *x);
115 bool exit_status_set_is_empty(ExitStatusSet *x);
116 bool exit_status_set_test(ExitStatusSet *x, int code, int status);