]> git.proxmox.com Git - systemd.git/blame - src/basic/exit-status.h
New upstream version 239
[systemd.git] / src / basic / exit-status.h
CommitLineData
52ad194e 1/* SPDX-License-Identifier: LGPL-2.1+ */
663996b3
MS
2#pragma once
3
663996b3 4#include <stdbool.h>
60f067b4 5
4c89c718
MP
6#include "hashmap.h"
7#include "macro.h"
663996b3 8#include "set.h"
60f067b4 9
5a920b42
MP
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
8a584da2 16enum {
663996b3
MS
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
b012e921 26 /* BSD's sysexits.h defines a couple EX_xyz exit codes in the range 64 … 78 */
663996b3 27
b012e921
MB
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. */
663996b3
MS
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,
60f067b4 53 _EXIT_RESERVED, /* used to be tcpwrap, don't reuse! */
663996b3
MS
54 EXIT_PAM,
55 EXIT_NETWORK,
56 EXIT_NAMESPACE,
57 EXIT_NO_NEW_PRIVILEGES,
60f067b4
JS
58 EXIT_SECCOMP,
59 EXIT_SELINUX_CONTEXT,
60 EXIT_PERSONALITY, /* 230 */
61 EXIT_APPARMOR_PROFILE,
62 EXIT_ADDRESS_FAMILIES,
63 EXIT_RUNTIME_DIRECTORY,
f5e65279 64 _EXIT_RESERVED2, /* used to be used by kdbus, don't reuse */
60f067b4 65 EXIT_CHOWN,
f47781d8 66 EXIT_SMACK_PROCESS_LABEL,
2897b343 67 EXIT_KEYRING,
f5e65279
MB
68 EXIT_STATE_DIRECTORY,
69 EXIT_CACHE_DIRECTORY,
70 EXIT_LOGS_DIRECTORY, /* 240 */
71 EXIT_CONFIGURATION_DIRECTORY,
8a584da2 72};
663996b3
MS
73
74typedef enum ExitStatusLevel {
5a920b42
MP
75 EXIT_STATUS_MINIMAL, /* only cover libc EXIT_STATUS/EXIT_FAILURE */
76 EXIT_STATUS_SYSTEMD, /* cover libc and systemd's own exit codes */
77 EXIT_STATUS_LSB, /* cover libc, systemd's own and LSB exit codes */
b012e921 78 EXIT_STATUS_FULL, /* cover libc, systemd's own, LSB and BSD (EX_xyz) exit codes */
663996b3
MS
79} ExitStatusLevel;
80
81typedef struct ExitStatusSet {
e842803a 82 Set *status;
663996b3
MS
83 Set *signal;
84} ExitStatusSet;
85
8a584da2 86const char* exit_status_to_string(int status, ExitStatusLevel level) _const_;
663996b3 87
8a584da2
MP
88typedef enum ExitClean {
89 EXIT_CLEAN_DAEMON,
90 EXIT_CLEAN_COMMAND,
91} ExitClean;
92
93bool is_clean_exit(int code, int status, ExitClean clean, ExitStatusSet *success_status);
e842803a
MB
94
95void exit_status_set_free(ExitStatusSet *x);
96bool exit_status_set_is_empty(ExitStatusSet *x);
e3bff60a 97bool exit_status_set_test(ExitStatusSet *x, int code, int status);