service: log signal name and core dumps in death message

Replace the bare signal number ("by signal: 9") with the symbolic
name ("killed by SIGKILL") and annotate when the kernel wrote a
core:("killed by SIGSEGV, core dumped").  Makes the restart line
self-explanatory and gives operators a strong breadcrumb when a
daemon dies unexpectedly.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg committed 2026-05-11 21:09:01 +02:00
1 parent 4a53f610cd
commit 30f2ca3b2e
1 file changed
+12 -7
+12 -7
View File
@@ -2828,13 +2828,18 @@ static void service_retry(svc_t *svc)
timeout = ((*restart_cnt) <= (svc->restart_max / 2)) ? 2000 : 5000; timeout = ((*restart_cnt) <= (svc->restart_max / 2)) ? 2000 : 5000;
/* If a longer timeout was specified in the conf, use that instead. */ /* If a longer timeout was specified in the conf, use that instead. */
svc->restart_tmo = max(svc->restart_tmo, timeout); svc->restart_tmo = max(svc->restart_tmo, timeout);
logit(LOG_CONSOLE|LOG_WARNING, "Service %s[%d] died (%s%d), restarting (retry in %d msec) (attempt: %d/%d)", if (WIFEXITED(svc->status))
svc_ident(svc, NULL, 0), svc->oldpid, logit(LOG_CONSOLE|LOG_WARNING,
WIFEXITED(svc->status) ? "with exit status: " : "by signal: ", "Service %s[%d] died (exit status: %d), restarting (retry in %d msec) (attempt: %d/%d)",
WIFEXITED(svc->status) ? WEXITSTATUS(svc->status) : WTERMSIG(svc->status), svc_ident(svc, NULL, 0), svc->oldpid, WEXITSTATUS(svc->status),
svc->restart_tmo, svc->restart_tmo, *restart_cnt, svc->restart_max);
*restart_cnt, else
svc->restart_max); logit(LOG_CONSOLE|LOG_WARNING,
"Service %s[%d] died (killed by %s%s), restarting (retry in %d msec) (attempt: %d/%d)",
svc_ident(svc, NULL, 0), svc->oldpid,
sig_name(WTERMSIG(svc->status)),
WCOREDUMP(svc->status) ? ", core dumped" : "",
svc->restart_tmo, *restart_cnt, svc->restart_max);
svc_unblock(svc); svc_unblock(svc);
service_step(svc); service_step(svc);