I am going to monitor dmesg by calling:
dmesg -c
every 1 second. I will look for specific strings in the output and then I will execute an action depending on the found strings.
However, I am worried about this scenario:
The Kernel prints a 20-chars message into the dmesg ring buffer, for example:
printk("Hello World !!!!!!!!"))
Right when the Kernel is printing a specific char... let's say the 10th char, the user calls dmesg
The last line was not completely written by the Kernel when we read the buffer
What will "dmesg -c" print?
a) A truncated line with only its first 10 chars (Hello Worl)
b) Omits the pending line
And then, in a next call of "dmesg -c", will it...
a) print the missing 10 chars of the pending line (d !!!!!!!!), or
b) print the full pending line?
This worries me because I will look for specific strings and if they get truncated then my idea will not work.
I am using Linux 2.6.31 and dmesg is run through busybox:
rwxrwxrwx 1 root root 7 Jun 3 07:36 dmesg -> busybox
BusyBox v1.19.3 () multi-call binary.
Usage: dmesg [-c] [-n LEVEL] [-s SIZE]
I have run dmesg several times and I have never noticed a truncated line, but it's better to know if it has only been luck.
Thanks.