Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Improve top(1) compatibility and interactive usefulness.
The toolbox -t option is really the standard -H option. Add -H so
I can switch dumpstate over.

We should also flush after each run so we don't arbitrarily truncate
at the stdio buffer size. (I'm pretty sure no one uses toolbox top
interactively, but it annoyed me while testing -H.)

Change-Id: Ib87cb541d1b21c48468614b2ef60b0cc62694c95
  • Loading branch information
enh-google committed Nov 13, 2015
1 parent 61a560a commit d7bd575
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions toolbox/top.c
Expand Up @@ -158,7 +158,7 @@ int top_main(int argc, char *argv[]) {
fprintf(stderr, "Invalid argument \"%s\" for option -s.\n", argv[i]);
exit(EXIT_FAILURE);
}
if (!strcmp(argv[i], "-t")) { threads = 1; continue; }
if (!strcmp(argv[i], "-H") || !strcmp(argv[i], "-t")) { threads = 1; continue; }
if (!strcmp(argv[i], "-h")) {
usage(argv[0]);
exit(EXIT_SUCCESS);
Expand Down Expand Up @@ -187,6 +187,7 @@ int top_main(int argc, char *argv[]) {
read_procs();
print_procs();
free_old_procs();
fflush(stdout);
}

return 0;
Expand Down Expand Up @@ -566,7 +567,7 @@ static void usage(char *cmd) {
" -n num Updates to show before exiting.\n"
" -d num Seconds to wait between updates.\n"
" -s col Column to sort by (cpu,vss,rss,thr).\n"
" -t Show threads instead of processes.\n"
" -H Show threads instead of processes.\n"
" -h Display this help screen.\n",
cmd);
}

0 comments on commit d7bd575

Please sign in to comment.