]>
Commit | Line | Data |
---|---|---|
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 | |
1afbdcb0 LP |
8 | ***/ |
9 | ||
9a57c629 | 10 | #include <stdbool.h> |
4d7213b2 | 11 | |
11c3a366 TA |
12 | #include "hashmap.h" |
13 | #include "macro.h" | |
93cc7779 | 14 | #include "set.h" |
4d7213b2 | 15 | |
c9d81ae8 LP |
16 | /* This defines pretty names for the LSB 'start' verb exit codes. Note that they shouldn't be confused with the LSB |
17 | * 'status' verb exit codes which are defined very differently. For details see: | |
18 | * | |
19 | * https://refspecs.linuxbase.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-generic/iniscrptact.html | |
20 | */ | |
21 | ||
65e3fd83 | 22 | enum { |
1afbdcb0 LP |
23 | /* EXIT_SUCCESS defined by libc */ |
24 | /* EXIT_FAILURE defined by libc */ | |
25 | EXIT_INVALIDARGUMENT = 2, | |
26 | EXIT_NOTIMPLEMENTED = 3, | |
27 | EXIT_NOPERMISSION = 4, | |
28 | EXIT_NOTINSTALLED = 5, | |
29 | EXIT_NOTCONFIGURED = 6, | |
30 | EXIT_NOTRUNNING = 7, | |
31 | ||
32 | /* The LSB suggests that error codes >= 200 are "reserved". We | |
33 | * use them here under the assumption that they hence are | |
c9d81ae8 | 34 | * unused by init scripts. */ |
1afbdcb0 LP |
35 | |
36 | EXIT_CHDIR = 200, | |
37 | EXIT_NICE, | |
38 | EXIT_FDS, | |
39 | EXIT_EXEC, | |
40 | EXIT_MEMORY, | |
41 | EXIT_LIMITS, | |
42 | EXIT_OOM_ADJUST, | |
43 | EXIT_SIGNAL_MASK, | |
44 | EXIT_STDIN, | |
45 | EXIT_STDOUT, | |
46 | EXIT_CHROOT, /* 210 */ | |
47 | EXIT_IOPRIO, | |
48 | EXIT_TIMERSLACK, | |
49 | EXIT_SECUREBITS, | |
50 | EXIT_SETSCHEDULER, | |
51 | EXIT_CPUAFFINITY, | |
52 | EXIT_GROUP, | |
53 | EXIT_USER, | |
54 | EXIT_CAPABILITIES, | |
55 | EXIT_CGROUP, | |
56 | EXIT_SETSID, /* 220 */ | |
57 | EXIT_CONFIRM, | |
58 | EXIT_STDERR, | |
7f8aa671 | 59 | _EXIT_RESERVED, /* used to be tcpwrap, don't reuse! */ |
ff01d048 | 60 | EXIT_PAM, |
4c2630eb | 61 | EXIT_NETWORK, |
8351ceae LP |
62 | EXIT_NAMESPACE, |
63 | EXIT_NO_NEW_PRIVILEGES, | |
7b52a628 | 64 | EXIT_SECCOMP, |
ac45f971 | 65 | EXIT_SELINUX_CONTEXT, |
eef65bf3 | 66 | EXIT_PERSONALITY, /* 230 */ |
4298d0b5 LP |
67 | EXIT_APPARMOR_PROFILE, |
68 | EXIT_ADDRESS_FAMILIES, | |
3900e5fd | 69 | EXIT_RUNTIME_DIRECTORY, |
be7e509e | 70 | _EXIT_RESERVED2, /* used to be used by kdbus, don't reuse */ |
3900e5fd | 71 | EXIT_CHOWN, |
2ca620c4 | 72 | EXIT_SMACK_PROCESS_LABEL, |
74dd6b51 | 73 | EXIT_KEYRING, |
3536f49e YW |
74 | EXIT_STATE_DIRECTORY, |
75 | EXIT_CACHE_DIRECTORY, | |
76 | EXIT_LOGS_DIRECTORY, /* 240 */ | |
77 | EXIT_CONFIGURATION_DIRECTORY, | |
65e3fd83 | 78 | }; |
1afbdcb0 LP |
79 | |
80 | typedef enum ExitStatusLevel { | |
c9d81ae8 LP |
81 | EXIT_STATUS_MINIMAL, /* only cover libc EXIT_STATUS/EXIT_FAILURE */ |
82 | EXIT_STATUS_SYSTEMD, /* cover libc and systemd's own exit codes */ | |
83 | EXIT_STATUS_LSB, /* cover libc, systemd's own and LSB exit codes */ | |
1afbdcb0 LP |
84 | EXIT_STATUS_FULL = EXIT_STATUS_LSB |
85 | } ExitStatusLevel; | |
86 | ||
96342de6 | 87 | typedef struct ExitStatusSet { |
3e2d435b | 88 | Set *status; |
96342de6 LN |
89 | Set *signal; |
90 | } ExitStatusSet; | |
91 | ||
65e3fd83 | 92 | const char* exit_status_to_string(int status, ExitStatusLevel level) _const_; |
1afbdcb0 | 93 | |
1f0958f6 LP |
94 | typedef enum ExitClean { |
95 | EXIT_CLEAN_DAEMON, | |
96 | EXIT_CLEAN_COMMAND, | |
97 | } ExitClean; | |
98 | ||
99 | bool is_clean_exit(int code, int status, ExitClean clean, ExitStatusSet *success_status); | |
37520c1b LP |
100 | |
101 | void exit_status_set_free(ExitStatusSet *x); | |
55ebf98c | 102 | bool exit_status_set_is_empty(ExitStatusSet *x); |
597466f4 | 103 | bool exit_status_set_test(ExitStatusSet *x, int code, int status); |