]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: mworker/cli: remove comment line for program when useless
authorWilliam Lallemand <wlallemand@haproxy.com>
Thu, 24 Oct 2024 12:39:41 +0000 (14:39 +0200)
committerWilliam Lallemand <wlallemand@haproxy.com>
Thu, 24 Oct 2024 12:39:41 +0000 (14:39 +0200)
Remove the '# programs' line on 'show proc' output when there are no
program.

src/mworker.c

index 7186cc1ac057cc380ece7ff9393b109a5ca422a2..5798b0de87a40fc83216f6c098215b1304349338 100644 (file)
@@ -599,6 +599,7 @@ static int cli_io_handler_show_proc(struct appctx *appctx)
        struct cli_showproc_ctx *ctx = appctx->svcctx;
        char *uptime = NULL;
        char *reloadtxt = NULL;
+       int program_nb = 0;
 
        if (up < 0) /* must never be negative because of clock drift */
                up = 0;
@@ -665,7 +666,6 @@ static int cli_io_handler_show_proc(struct appctx *appctx)
        }
 
        /* displays external process */
-       chunk_appendf(&trash, "# programs\n");
        old = 0;
        list_for_each_entry(child, &proc_list, list) {
                up = date.tv_sec - child->timestamp;
@@ -679,6 +679,9 @@ static int cli_io_handler_show_proc(struct appctx *appctx)
                        old++;
                        continue;
                }
+               if (program_nb == 0)
+                       chunk_appendf(&trash, "# programs\n");
+               program_nb++;
                memprintf(&uptime, "%dd%02dh%02dm%02ds", up / 86400, (up % 86400) / 3600, (up % 3600) / 60, (up % 60));
                chunk_appendf(&trash, "%-15u %-15s %-15d %-15s %-15s\n", child->pid, child->id, child->reloads, uptime, "-");
                ha_free(&uptime);