Skip to content

Commit e134176

Browse files
committed
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>
1 parent b52053e commit e134176

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

src/service.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2824,13 +2824,18 @@ static void service_retry(svc_t *svc)
28242824
timeout = ((*restart_cnt) <= (svc->restart_max / 2)) ? 2000 : 5000;
28252825
/* If a longer timeout was specified in the conf, use that instead. */
28262826
svc->restart_tmo = max(svc->restart_tmo, timeout);
2827-
logit(LOG_CONSOLE|LOG_WARNING, "Service %s[%d] died (%s%d), restarting (retry in %d msec) (attempt: %d/%d)",
2828-
svc_ident(svc, NULL, 0), svc->oldpid,
2829-
WIFEXITED(svc->status) ? "with exit status: " : "by signal: ",
2830-
WIFEXITED(svc->status) ? WEXITSTATUS(svc->status) : WTERMSIG(svc->status),
2831-
svc->restart_tmo,
2832-
*restart_cnt,
2833-
svc->restart_max);
2827+
if (WIFEXITED(svc->status))
2828+
logit(LOG_CONSOLE|LOG_WARNING,
2829+
"Service %s[%d] died (exit status: %d), restarting (retry in %d msec) (attempt: %d/%d)",
2830+
svc_ident(svc, NULL, 0), svc->oldpid, WEXITSTATUS(svc->status),
2831+
svc->restart_tmo, *restart_cnt, svc->restart_max);
2832+
else
2833+
logit(LOG_CONSOLE|LOG_WARNING,
2834+
"Service %s[%d] died (killed by %s%s), restarting (retry in %d msec) (attempt: %d/%d)",
2835+
svc_ident(svc, NULL, 0), svc->oldpid,
2836+
sig_name(WTERMSIG(svc->status)),
2837+
WCOREDUMP(svc->status) ? ", core dumped" : "",
2838+
svc->restart_tmo, *restart_cnt, svc->restart_max);
28342839

28352840
svc_unblock(svc);
28362841
service_step(svc);

0 commit comments

Comments
 (0)