From 49b99584a42794c0f4f8df79cb1553f9a80c0c27 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Sun, 13 Feb 2022 23:03:30 +0100 Subject: [PATCH] Verify the kernel log fifo is a proper character device Issue #48 describes a problem with 100% CPU load in a container use-case. Turns out one of the issues was that /dev/kmsg was not a proper character device. This patch adds a very basic check to ensure /dev/kmsg is usable. Signed-off-by: Joachim Wiberg --- src/syslogd.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/syslogd.c b/src/syslogd.c index 227b956..484f05b 100644 --- a/src/syslogd.c +++ b/src/syslogd.c @@ -584,14 +584,11 @@ static void kernel_cb(int fd, void *arg) static int opensys(const char *file) { -// struct stat st; + struct stat st; int fd; -// sleep(300); -// return 1; - -// if (stat(file, &st) || !S_ISCHR(st.st_mode)) -// return 1; + if (stat(file, &st) || !S_ISCHR(st.st_mode)) + return 1; fd = open(file, O_RDONLY | O_NONBLOCK | O_CLOEXEC, 0); if (fd < 0)