From b4f385d2e0babdee341b3ec733ce3881189a81ac Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Thu, 8 Sep 2016 17:11:52 +0200 Subject: [PATCH] Only log to stderr if opening /dev/kmsg failed for early logging This patch prevents double critical/error messages from being printed on the console when there is no syslog daemon running yet. Signed-off-by: Joachim Nilsson --- helpers.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/helpers.c b/helpers.c index 1bc5546b..a33340fc 100644 --- a/helpers.c +++ b/helpers.c @@ -197,9 +197,9 @@ void logit(int prio, const char *fmt, ...) fclose(fp); } else { fprintf(stderr, "Failed opening /dev/kmsg for appending ...\n"); + if (prio <= LOG_ERR) + vfprintf(stderr, fmt, ap); } - if (prio <= LOG_ERR) - vfprintf(stderr, fmt, ap); va_end(ap); return; }