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