X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fsystemctl%2Fsystemctl.c;h=f3d7fc8d6e5c0573a5e7442180e1b41ce7c5c0ab;hb=7de80bfe2e61d5818601ccfddbadad3b7703ed70;hp=03720f411d7b41fc4cdebc09b5ed8bb8308c1e25;hpb=99813a19122932da2cf55fecaf06446dcf7989a2;p=elogind.git diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index 03720f411..f3d7fc8d6 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -456,7 +456,7 @@ static int output_units_list(const UnitInfo *unit_infos, unsigned c) { } if (circle_len > 0) - printf("%s%s%s", on_circle, circle ? draw_special_char(DRAW_BLACK_CIRCLE) : " ", off_circle); + printf("%s%s%s ", on_circle, circle ? draw_special_char(DRAW_BLACK_CIRCLE) : " ", off_circle); printf("%s%-*s%s %s%-*s%s %s%-*s %-*s%s %-*s", on_active, id_len, id, off_active, @@ -3170,6 +3170,7 @@ typedef struct UnitStatusInfo { const char *status_text; const char *pid_file; bool running:1; + int status_errno; usec_t start_timestamp; usec_t exit_timestamp; @@ -3441,6 +3442,8 @@ static void print_status_info( if (i->status_text) printf(" Status: \"%s\"\n", i->status_text); + if (i->status_errno > 0) + printf(" Error: %i (%s)\n", i->status_errno, strerror(i->status_errno)); if (i->control_group && (i->main_pid > 0 || i->control_pid > 0 || @@ -3500,50 +3503,11 @@ static void show_unit_help(UnitStatusInfo *i) { return; } - STRV_FOREACH(p, i->documentation) { - - if (startswith(*p, "man:")) { - const char *args[4] = { "man", NULL, NULL, NULL }; - _cleanup_free_ char *page = NULL, *section = NULL; - char *e = NULL; - pid_t pid; - size_t k; - - k = strlen(*p); - - if ((*p)[k-1] == ')') - e = strrchr(*p, '('); - - if (e) { - page = strndup((*p) + 4, e - *p - 4); - section = strndup(e + 1, *p + k - e - 2); - if (!page || !section) { - log_oom(); - return; - } - - args[1] = section; - args[2] = page; - } else - args[1] = *p + 4; - - pid = fork(); - if (pid < 0) { - log_error("Failed to fork: %m"); - continue; - } - - if (pid == 0) { - /* Child */ - execvp(args[0], (char**) args); - log_error("Failed to execute man: %m"); - _exit(EXIT_FAILURE); - } - - wait_for_terminate(pid, NULL); - } else + STRV_FOREACH(p, i->documentation) + if (startswith(*p, "man:")) + show_man_page(*p + 4, false); + else log_info("Can't show: %s", *p); - } } static int status_property(const char *name, sd_bus_message *m, UnitStatusInfo *i, const char *contents) { @@ -3661,6 +3625,8 @@ static int status_property(const char *name, sd_bus_message *m, UnitStatusInfo * i->exit_code = (int) j; else if (streq(name, "ExecMainStatus")) i->exit_status = (int) j; + else if (streq(name, "StatusErrno")) + i->status_errno = (int) j; break; } @@ -5033,11 +4999,10 @@ static int enable_sysv_units(const char *verb, char **args) { _cleanup_free_ char *path = NULL; if (!isempty(arg_root)) - asprintf(&path, "%s/%s/%s", arg_root, *k, name); + j = asprintf(&path, "%s/%s/%s", arg_root, *k, name); else - asprintf(&path, "%s/%s", *k, name); - - if (!path) { + j = asprintf(&path, "%s/%s", *k, name); + if (j < 0) { r = log_oom(); goto finish; } @@ -5051,10 +5016,10 @@ static int enable_sysv_units(const char *verb, char **args) { continue; if (!isempty(arg_root)) - asprintf(&p, "%s/" SYSTEM_SYSVINIT_PATH "/%s", arg_root, name); + j = asprintf(&p, "%s/" SYSTEM_SYSVINIT_PATH "/%s", arg_root, name); else - asprintf(&p, SYSTEM_SYSVINIT_PATH "/%s", name); - if (!p) { + j = asprintf(&p, SYSTEM_SYSVINIT_PATH "/%s", name); + if (j < 0) { r = log_oom(); goto finish; }