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