On Tue, 5 Nov 2019 12:03:04 -0800 Michael Forney <[email protected]> wrote:
> On 2019-11-05, Mattias Andrée <[email protected]> wrote: > > On Sat, 2 Nov 2019 12:33:58 -0700 > > Michael Forney <[email protected]> wrote: > > > >> I've never used vmstat before, but this looks pretty good overall and > >> seems to work well. > >> > >> On 2019-10-05, Mattias Andrée <[email protected]> wrote: > >> > + goto beginning; > >> > + for (; argc && (argc < 2 || i < count); i++) { > >> > >> Why not just set count = 1 when argc < 2? > > > > Because that would stop the loop after 1 iteration. > > If argc == 1, the loop should be infinite. > > Oh, right. > > > An alternative that would work is: > > > > for (;;) { > > load_vm(&vm[i & 1]); > > print_vm(&vm[i & 1], &vm[~i & 1], active_mem, timestamp, > > one_header ? !i : > > (i % 50 == 0)); > > i++; > > if (!argc || (argc == 2 && i == count)) > > break; > > clock_nanosleep(CLOCK_MONOTONIC, 0, &delay, NULL); > > } > > FWIW, I like this approach. I will make a new version with that approach then.
