aboutsummaryrefslogtreecommitdiff
path: root/toys/other/vmstat.c
diff options
context:
space:
mode:
Diffstat (limited to 'toys/other/vmstat.c')
-rw-r--r--toys/other/vmstat.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/toys/other/vmstat.c b/toys/other/vmstat.c
index ef560fa9..8e131d9f 100644
--- a/toys/other/vmstat.c
+++ b/toys/other/vmstat.c
@@ -76,16 +76,15 @@ void vmstat_main(void)
{
struct vmstat_proc top[2];
int i, loop_delay = 0, loop_max = 0;
- unsigned loop, rows = (toys.optflags & FLAG_n) ? 0 : 25,
- page_kb = sysconf(_SC_PAGESIZE)/1024;
+ unsigned loop, rows = 25, page_kb = sysconf(_SC_PAGESIZE)/1024;
char *headers="r\0b\0swpd\0free\0buff\0cache\0si\0so\0bi\0bo\0in\0cs\0us\0"
"sy\0id\0wa", lengths[] = {2,2,6,6,6,6,4,4,5,5,4,4,2,2,2,2};
memset(top, 0, sizeof(top));
if (toys.optc) loop_delay = atolx_range(toys.optargs[0], 0, INT_MAX);
- if (toys.optc > 1) loop_max = atolx_range(toys.optargs[1], 1, INT_MAX) - 1;
+ if (toys.optc > 1) loop_max = atolx_range(toys.optargs[1], 1, INT_MAX);
- for (loop = 0; !loop_max || loop <= loop_max; loop++) {
+ for (loop = 0; !loop_max || loop < loop_max; loop++) {
unsigned idx = loop&1, offset = 0, expected = 0;
uint64_t units, total_hz, *ptr = (uint64_t *)(top+idx),
*oldptr = (uint64_t *)(top+!idx);
@@ -96,7 +95,7 @@ void vmstat_main(void)
if (rows>3 && !(loop % (rows-3))) {
char *header = headers;
- if (isatty(1)) terminal_size(0, &rows);
+ if ((!toys.optflags&FLAG_n) && isatty(1)) terminal_size(0, &rows);
else rows = 0;
printf("procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----\n");