]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/exit-status.c
1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
4 This file is part of systemd.
6 Copyright 2010 Lennart Poettering
8 systemd is free software; you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
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 General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with systemd; If not, see <http://www.gnu.org/licenses/>.
25 #include "exit-status.h"
27 const char* exit_status_to_string(ExitStatus status
, ExitStatusLevel level
) {
29 /* We cast to int here, so that -Wenum doesn't complain that
30 * EXIT_SUCCESS/EXIT_FAILURE aren't in the enum */
32 switch ((int) status
) {
42 if (level
== EXIT_STATUS_SYSTEMD
|| level
== EXIT_STATUS_LSB
) {
43 switch ((int) status
) {
66 case EXIT_SIGNAL_MASK
:
87 case EXIT_SETSCHEDULER
:
88 return "SETSCHEDULER";
90 case EXIT_CPUAFFINITY
:
99 case EXIT_CAPABILITIES
:
100 return "CAPABILITIES";
128 if (level
== EXIT_STATUS_LSB
) {
129 switch ((int) status
) {
131 case EXIT_INVALIDARGUMENT
:
132 return "INVALIDARGUMENT";
134 case EXIT_NOTIMPLEMENTED
:
135 return "NOTIMPLEMENTED";
137 case EXIT_NOPERMISSION
:
138 return "NOPERMISSION";
140 case EXIT_NOTINSTALLED
:
141 return "NOTINSSTALLED";
143 case EXIT_NOTCONFIGURED
:
144 return "NOTCONFIGURED";
146 case EXIT_NOTRUNNING
:
155 bool is_clean_exit(int code
, int status
) {
157 if (code
== CLD_EXITED
)
160 /* If a daemon does not implement handlers for some of the
161 * signals that's not considered an unclean shutdown */
162 if (code
== CLD_KILLED
)
172 bool is_clean_exit_lsb(int code
, int status
) {
174 if (is_clean_exit(code
, status
))
178 code
== CLD_EXITED
&&
179 (status
== EXIT_NOTINSTALLED
|| status
== EXIT_NOTCONFIGURED
);