From: Matthew Dillon Date: Tue, 29 Nov 2011 21:41:54 +0000 (-0800) Subject: dmesg - Don't fail when the kernel is adding to the dmesg quickly X-Git-Tag: v3.0.0~532 X-Git-Url: http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/35bb81cee37e18ff19a165bb1ec20e52fadbe0b9 dmesg - Don't fail when the kernel is adding to the dmesg quickly * If the kernel is quickly adding to the dmesg buffer and has not started recycling the FIFO the increasing size of the buffer will exceed the probed size. * Add another 4K to the probed size to try to deal with this case. --- diff --git a/sbin/dmesg/dmesg.c b/sbin/dmesg/dmesg.c index 09da87f..93e7cf5 100644 --- a/sbin/dmesg/dmesg.c +++ b/sbin/dmesg/dmesg.c @@ -98,6 +98,7 @@ main(int argc, char **argv) /* Running kernel. Use sysctl. */ if (sysctlbyname("kern.msgbuf", NULL, &buflen, NULL, 0) == -1) err(1, "sysctl kern.msgbuf"); + buflen += 4096; /* add some slop */ if ((bp = malloc(buflen)) == NULL) errx(1, "malloc failed"); if (sysctlbyname("kern.msgbuf", bp, &buflen, NULL, 0) == -1)