mirror of
https://github.com/troglobit/finit.git
synced 2026-11-06 15:51:03 +00:00
initctl: show halted state status reason in bold everywhere
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
1 parent
79f7a8ccfb
commit
bdf5f8fc90
1 file changed
+18
-2
+18
-2
@@ -541,6 +541,22 @@ static char *svc_command(svc_t *svc, char *cmd, size_t len)
|
|||||||
return cmd;
|
return cmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char *status(svc_t *svc)
|
||||||
|
{
|
||||||
|
static char buf[25];
|
||||||
|
int bold = !plain;
|
||||||
|
char *s;
|
||||||
|
|
||||||
|
s = svc_status(svc);
|
||||||
|
if (svc->state != SVC_HALTED_STATE)
|
||||||
|
bold = 0;
|
||||||
|
|
||||||
|
snprintf(buf, sizeof(buf), "%s%-8.8s%s",
|
||||||
|
bold ? "\e[1m" : "", s, bold ? "\e[0m" : "");
|
||||||
|
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
static int show_status(char *arg)
|
static int show_status(char *arg)
|
||||||
{
|
{
|
||||||
char ident[MAX_IDENT_LEN];
|
char ident[MAX_IDENT_LEN];
|
||||||
@@ -557,7 +573,7 @@ static int show_status(char *arg)
|
|||||||
if (!svc)
|
if (!svc)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
printf("Status : %s%s%s\n", !plain ? "\e[1m" : "", svc_status(svc), !plain ? "\e[0m" : "");
|
printf("Status : %s\n", status(svc));
|
||||||
printf("Identity : %s\n", svc_ident(svc, ident, sizeof(ident)));
|
printf("Identity : %s\n", svc_ident(svc, ident, sizeof(ident)));
|
||||||
printf("Description : %s\n", svc->desc);
|
printf("Description : %s\n", svc->desc);
|
||||||
printf("Origin : %s\n", svc->file[0] ? svc->file : "built-in");
|
printf("Origin : %s\n", svc->file[0] ? svc->file : "built-in");
|
||||||
@@ -594,7 +610,7 @@ static int show_status(char *arg)
|
|||||||
printf("%-*d ", pw, svc->pid);
|
printf("%-*d ", pw, svc->pid);
|
||||||
|
|
||||||
svc_ident(svc, ident, sizeof(ident));
|
svc_ident(svc, ident, sizeof(ident));
|
||||||
printf("%-*s %-8s ", iw, ident, svc_status(svc));
|
printf("%-*s %s ", iw, ident, status(svc));
|
||||||
|
|
||||||
lvls = runlevel_string(runlevel, svc->runlevels);
|
lvls = runlevel_string(runlevel, svc->runlevels);
|
||||||
if (strchr(lvls, '\e'))
|
if (strchr(lvls, '\e'))
|
||||||
|
|||||||
Reference in new issue
Block a user