]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
systemctl: fix output alignment in "systemctl status"
authorLennart Poettering <lennart@poettering.net>
Thu, 21 Jul 2016 16:05:58 +0000 (18:05 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 22 Jul 2016 10:59:36 +0000 (12:59 +0200)
If we show both a control and a main PID for a service fix this line in the
output of "systemctl status":

 Main PID: 19670 (sleep);         : 19671 (sleep)

to become this:

 Main PID: 19670 (sleep); Control PID: 19671 (sleep)

src/systemctl/systemctl.c

index d3f437411a9bbc5f4c4d78f2b307863cf19141db..ab3c4fb585721e01ab839bc61ce264248dda2abd 100644 (file)
@@ -3761,7 +3761,7 @@ static void print_status_info(
 
                         if (i->running) {
                                 _cleanup_free_ char *comm = NULL;
-                                get_process_comm(i->main_pid, &comm);
+                                (void) get_process_comm(i->main_pid, &comm);
                                 if (comm)
                                         printf(" (%s)", comm);
                         } else if (i->exit_code > 0) {
@@ -3780,17 +3780,19 @@ static void print_status_info(
                                         printf("signal=%s", signal_to_string(i->exit_status));
                                 printf(")");
                         }
-
-                        if (i->control_pid > 0)
-                                printf(";");
                 }
 
                 if (i->control_pid > 0) {
                         _cleanup_free_ char *c = NULL;
 
-                        printf(" %8s: "PID_FMT, i->main_pid ? "" : " Control", i->control_pid);
+                        if (i->main_pid > 0)
+                                fputs("; Control PID: ", stdout);
+                        else
+                                fputs("Cntrl PID: ", stdout); /* if first in column, abbreviated so it fits alignment */
+
+                        printf(PID_FMT, i->control_pid);
 
-                        get_process_comm(i->control_pid, &c);
+                        (void) get_process_comm(i->control_pid, &c);
                         if (c)
                                 printf(" (%s)", c);
                 }