<div dir="ltr">+2. i reproduced the bug, and this patch fixes it.</div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, May 9, 2015 at 10:47 PM, Graham Watt <span dir="ltr"><<a href="mailto:gmwatt@gmail.com" target="_blank">gmwatt@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">There's a bug in vmstat that causes junk to be printed instead of the<br>
headers when repeating. This can be duplicated by running `vmstat 1`<br>
and waiting for the headers to be printed again.<br>
Here is a patch for the issue.<br>
<br>
<br>
diff --git a/toys/other/vmstat.c b/toys/other/vmstat.c<br>
index eed7945..2685c11 100644<br>
--- a/toys/other/vmstat.c<br>
+++ b/toys/other/vmstat.c<br>
@@ -77,8 +77,9 @@ void vmstat_main(void)<br>
int i, loop_delay = 0, loop_max = 0;<br>
unsigned loop, rows = (toys.optflags & FLAG_n) ? 0 : 25,<br>
page_kb = sysconf(_SC_PAGESIZE)/1024;<br>
- char *headers="r\0b\0swpd\0free\0buff\0cache\0si\0so\0bi\0bo\0in\0cs\0us\0"<br>
- "sy\0id\0wa", lengths[] = {2,2,6,6,6,6,4,4,5,5,4,4,2,2,2,2};<br>
+ char *headers[]={"r","b","swpd","free","buff","cache","si","so","bi","bo",<br>
+ "in","cs","us","sy","id","wa"},<br>
+ lengths[] = {2,2,6,6,6,6,4,4,5,5,4,4,2,2,2,2};<br>
<br>
memset(top, 0, sizeof(top));<br>
if (toys.optc) loop_delay = atolx_range(toys.optargs[0], 0, INT_MAX);<br>
@@ -99,8 +100,7 @@ void vmstat_main(void)<br>
printf("procs -----------memory---------- ---swap-- -----io----<br>
-system-- ----cpu----\n");<br>
<br>
for (i=0; i<sizeof(lengths); i++) {<br>
- printf(" %*s"+!i, lengths[i], headers);<br>
- headers += strlen(headers)+1;<br>
+ printf(" %*s"+!i, lengths[i], headers[i]);<br>
}<br>
xputc('\n');<br>
}<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Graham Watt<br>
_______________________________________________<br>
Toybox mailing list<br>
<a href="mailto:Toybox@lists.landley.net">Toybox@lists.landley.net</a><br>
<a href="http://lists.landley.net/listinfo.cgi/toybox-landley.net" target="_blank">http://lists.landley.net/listinfo.cgi/toybox-landley.net</a><br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">Elliott Hughes - <a href="http://who/enh" target="_blank">http://who/enh</a> - <a href="http://jessies.org/~enh/" target="_blank">http://jessies.org/~enh/</a><br>Android native code/tools questions? Mail me/drop by/add me as a reviewer.</div>
</div>