diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/exit-status.c | 29 | ||||
-rw-r--r-- | src/exit-status.h | 5 | ||||
-rw-r--r-- | src/mount.c | 1 | ||||
-rw-r--r-- | src/remount-api-vfs.c | 1 | ||||
-rw-r--r-- | src/service.c | 1 | ||||
-rw-r--r-- | src/socket.c | 1 | ||||
-rw-r--r-- | src/swap.c | 1 | ||||
-rw-r--r-- | src/systemctl.c | 23 | ||||
-rw-r--r-- | src/util.c | 27 | ||||
-rw-r--r-- | src/util.h | 3 |
10 files changed, 60 insertions, 32 deletions
diff --git a/src/exit-status.c b/src/exit-status.c index 4fed3c70a4..9b7c027b43 100644 --- a/src/exit-status.c +++ b/src/exit-status.c @@ -20,6 +20,7 @@ ***/ #include <stdlib.h> +#include <sys/wait.h> #include "exit-status.h" @@ -143,3 +144,31 @@ const char* exit_status_to_string(ExitStatus status, ExitStatusLevel level) { return NULL; } + + +bool is_clean_exit(int code, int status) { + + if (code == CLD_EXITED) + return status == 0; + + /* If a daemon does not implement handlers for some of the + * signals that's not considered an unclean shutdown */ + if (code == CLD_KILLED) + return + status == SIGHUP || + status == SIGINT || + status == SIGTERM || + status == SIGPIPE; + + return false; +} + +bool is_clean_exit_lsb(int code, int status) { + + if (is_clean_exit(code, status)) + return true; + + return + code == CLD_EXITED && + (status == EXIT_NOTINSTALLED || status == EXIT_NOTCONFIGURED); +} diff --git a/src/exit-status.h b/src/exit-status.h index 178bdf6d61..28f03a5911 100644 --- a/src/exit-status.h +++ b/src/exit-status.h @@ -22,6 +22,8 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>. ***/ +#include <stdbool.h> + typedef enum ExitStatus { /* EXIT_SUCCESS defined by libc */ /* EXIT_FAILURE defined by libc */ @@ -75,4 +77,7 @@ typedef enum ExitStatusLevel { const char* exit_status_to_string(ExitStatus status, ExitStatusLevel level); +bool is_clean_exit(int code, int status); +bool is_clean_exit_lsb(int code, int status); + #endif diff --git a/src/mount.c b/src/mount.c index 08e99141b1..f978a5467d 100644 --- a/src/mount.c +++ b/src/mount.c @@ -36,6 +36,7 @@ #include "dbus-mount.h" #include "special.h" #include "bus-errors.h" +#include "exit-status.h" static const UnitActiveState state_translation_table[_MOUNT_STATE_MAX] = { [MOUNT_DEAD] = UNIT_INACTIVE, diff --git a/src/remount-api-vfs.c b/src/remount-api-vfs.c index 8cdf7e8758..5b1872833a 100644 --- a/src/remount-api-vfs.c +++ b/src/remount-api-vfs.c @@ -31,6 +31,7 @@ #include "util.h" #include "set.h" #include "mount-setup.h" +#include "exit-status.h" /* Goes through /etc/fstab and remounts all API file systems, applying * options that are in /etc/fstab that systemd might not have diff --git a/src/service.c b/src/service.c index 431bccc4e1..4115e52901 100644 --- a/src/service.c +++ b/src/service.c @@ -34,6 +34,7 @@ #include "dbus-service.h" #include "special.h" #include "bus-errors.h" +#include "exit-status.h" #define COMMENTS "#;\n" #define NEWLINES "\n\r" diff --git a/src/socket.c b/src/socket.c index 7dc205abde..3bb8862ca9 100644 --- a/src/socket.c +++ b/src/socket.c @@ -41,6 +41,7 @@ #include "special.h" #include "bus-errors.h" #include "label.h" +#include "exit-status.h" static const UnitActiveState state_translation_table[_SOCKET_STATE_MAX] = { [SOCKET_DEAD] = UNIT_INACTIVE, diff --git a/src/swap.c b/src/swap.c index 6ab99d5712..23a98dd63f 100644 --- a/src/swap.c +++ b/src/swap.c @@ -36,6 +36,7 @@ #include "dbus-swap.h" #include "special.h" #include "bus-errors.h" +#include "exit-status.h" static const UnitActiveState state_translation_table[_SWAP_STATE_MAX] = { [SWAP_DEAD] = UNIT_INACTIVE, diff --git a/src/systemctl.c b/src/systemctl.c index f93f2aa480..fb3430048c 100644 --- a/src/systemctl.c +++ b/src/systemctl.c @@ -1847,15 +1847,31 @@ static void print_status_info(UnitStatusInfo *i) { LIST_FOREACH(exec, p, i->exec) { char *t; + bool good; /* Only show exited processes here */ if (p->code == 0) continue; t = strv_join(p->argv, " "); - printf("\t Process: %u %s=%s (code=%s, ", p->pid, p->name, strna(t), sigchld_code_to_string(p->code)); + printf("\t Process: %u %s=%s ", p->pid, p->name, strna(t)); free(t); +#ifdef HAVE_SYSV_COMPAT + if (i->is_sysv) + good = is_clean_exit_lsb(p->code, p->status); + else +#endif + good = is_clean_exit(p->code, p->status); + + if (!good) { + on = ansi_highlight(true); + off = ansi_highlight(false); + } else + on = off = ""; + + printf("%s(code=%s, ", on, sigchld_code_to_string(p->code)); + if (p->code == CLD_EXITED) { const char *c; @@ -1870,7 +1886,10 @@ static void print_status_info(UnitStatusInfo *i) { } else printf("signal=%s", signal_to_string(p->status)); - printf(")\n"); + + printf(")%s\n", off); + + on = off = NULL; if (i->main_pid == p->pid && i->start_timestamp == p->start_timestamp && diff --git a/src/util.c b/src/util.c index 30a3b058fc..d3876ded5b 100644 --- a/src/util.c +++ b/src/util.c @@ -2617,33 +2617,6 @@ int make_null_stdio(void) { return make_stdio(null_fd); } -bool is_clean_exit(int code, int status) { - - if (code == CLD_EXITED) - return status == 0; - - /* If a daemon does not implement handlers for some of the - * signals that's not considered an unclean shutdown */ - if (code == CLD_KILLED) - return - status == SIGHUP || - status == SIGINT || - status == SIGTERM || - status == SIGPIPE; - - return false; -} - -bool is_clean_exit_lsb(int code, int status) { - - if (is_clean_exit(code, status)) - return true; - - return - code == CLD_EXITED && - (status == EXIT_NOTINSTALLED || status == EXIT_NOTCONFIGURED); -} - bool is_device_path(const char *path) { /* Returns true on paths that refer to a device, either in diff --git a/src/util.h b/src/util.h index e9ad881e9c..c8cae703a2 100644 --- a/src/util.h +++ b/src/util.h @@ -267,9 +267,6 @@ char *format_timespan(char *buf, size_t l, usec_t t); int make_stdio(int fd); int make_null_stdio(void); -bool is_clean_exit(int code, int status); -bool is_clean_exit_lsb(int code, int status); - unsigned long long random_ull(void); #define DEFINE_STRING_TABLE_LOOKUP(name,type) \ |