]> git.proxmox.com Git - systemd.git/blame - src/basic/exit-status.h
Imported Upstream version 231
[systemd.git] / src / basic / exit-status.h
CommitLineData
663996b3
MS
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>
60f067b4 23
4c89c718
MP
24#include "hashmap.h"
25#include "macro.h"
663996b3 26#include "set.h"
60f067b4 27
5a920b42
MP
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
663996b3
MS
34typedef enum ExitStatus {
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
5a920b42 46 * unused by init scripts. */
663996b3
MS
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,
60f067b4 71 _EXIT_RESERVED, /* used to be tcpwrap, don't reuse! */
663996b3
MS
72 EXIT_PAM,
73 EXIT_NETWORK,
74 EXIT_NAMESPACE,
75 EXIT_NO_NEW_PRIVILEGES,
60f067b4
JS
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_MAKE_STARTER,
83 EXIT_CHOWN,
f47781d8 84 EXIT_SMACK_PROCESS_LABEL,
663996b3
MS
85} ExitStatus;
86
87typedef enum ExitStatusLevel {
5a920b42
MP
88 EXIT_STATUS_MINIMAL, /* only cover libc EXIT_STATUS/EXIT_FAILURE */
89 EXIT_STATUS_SYSTEMD, /* cover libc and systemd's own exit codes */
90 EXIT_STATUS_LSB, /* cover libc, systemd's own and LSB exit codes */
663996b3
MS
91 EXIT_STATUS_FULL = EXIT_STATUS_LSB
92} ExitStatusLevel;
93
94typedef struct ExitStatusSet {
e842803a 95 Set *status;
663996b3
MS
96 Set *signal;
97} ExitStatusSet;
98
99const char* exit_status_to_string(ExitStatus status, ExitStatusLevel level) _const_;
100
101bool is_clean_exit(int code, int status, ExitStatusSet *success_status);
102bool is_clean_exit_lsb(int code, int status, ExitStatusSet *success_status);
e842803a
MB
103
104void exit_status_set_free(ExitStatusSet *x);
105bool exit_status_set_is_empty(ExitStatusSet *x);
e3bff60a 106bool exit_status_set_test(ExitStatusSet *x, int code, int status);