Fix #8: kernel messages duplicated to console

When building the sysklogd project --without-klogd we must disable the
kernel logging to console on Linux.  This fix depends on how the sysctl
setting `kernel.printk` is configured.  The patch only calls the kernel
to set console_loglevel to minimum_console_loglevel.

See the kernel docs for details:

  https://www.kernel.org/doc/Documentation/sysctl/kernel.txt

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson
2019-12-07 09:14:10 +01:00
parent a7fe2ef700
commit 8aa2060312
2 changed files with 28 additions and 0 deletions

View File

@@ -385,6 +385,8 @@ int main(int argc, char *argv[])
/* Attempt to open kernel log pipe */
if (opensys(_PATH_KLOG))
warn("Kernel logging disabled, failed opening %s", _PATH_KLOG);
else
kern_console_off();
#endif
if (!Foreground) {
@@ -2016,6 +2018,10 @@ void die(int signo)
free(pe);
}
#ifndef KLOGD
kern_console_on();
#endif
exit(0);
}