From b49ddae21b619b2b4266ad755513af08055b27d0 Mon Sep 17 00:00:00 2001 From: William Lallemand Date: Thu, 24 Oct 2024 14:39:41 +0200 Subject: [PATCH] MINOR: mworker/cli: remove comment line for program when useless Remove the '# programs' line on 'show proc' output when there are no program. --- src/mworker.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/mworker.c b/src/mworker.c index 7186cc1ac0..5798b0de87 100644 --- a/src/mworker.c +++ b/src/mworker.c @@ -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);