Re: How to configure flushing klog by syslog

RVP <[email protected]>
Newsgroups gmane.os.netbsd.devel.kernel
Message-ID <[email protected]>
> I am trying to use printf() in kernel module for debugging purposes and
> I cannot find how to force flushing klog by syslogd.
> I found syslogd option -S. Manual page says: "
> -S               Sync kernel messages to disk immediately.
> 
> After adding to rc.conf: syslogd_flags="-S" nothing changes.
>

Looks like a missing wakeup, so reading from /dev/klog just waits until some
_other_ function chances to wake up the sleeper by calling logwakeup().

Can you try the patch below? If it works, then you can file a PR (I've done
only 2 and the other functions which use the TOLOG flag might need the same
treatment).

---START PATCH---
--- src/sys/kern/subr_prf.c.orig	2023-08-29 21:23:14.000000000 +0000
+++ src/sys/kern/subr_prf.c	2025-01-13 08:37:45.789743655 +0000
@@ -1059,6 +1059,9 @@
  	va_start(ap, fmt);
  	vprintf_flags(TOLOG, fmt, ap);
  	va_end(ap);
+
+	if (!panicstr)
+		logwakeup();
  }

  /*
@@ -1104,6 +1107,9 @@
  	va_start(ap, fmt);
  	vprintf_flags(TOCONS | TOLOG, fmt, ap);
  	va_end(ap);
+
+	if (!panicstr)
+		logwakeup();
  }

  /*
---END PATCH---

-RVP
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.