summaryrefslogtreecommitdiff
path: root/usr.bin/top/top.c
diff options
context:
space:
mode:
authorTed Unangst <tedu@cvs.openbsd.org>2009-12-10 13:16:03 +0000
committerTed Unangst <tedu@cvs.openbsd.org>2009-12-10 13:16:03 +0000
commita47070bc84c4e45ef117cf107e671a6c7aa1bc03 (patch)
treeff20a7201d778690951d590ff102defa93724dc5 /usr.bin/top/top.c
parent864a9954f2f11f85ca75e63be11507fbb7a0290c (diff)
add an option '1' to display all cpu stats combined. helps save space
with increasing processor counts. ok deraadt (kettenis otto)
Diffstat (limited to 'usr.bin/top/top.c')
-rw-r--r--usr.bin/top/top.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/usr.bin/top/top.c b/usr.bin/top/top.c
index 1dceaca5ac5..716772c6a4e 100644
--- a/usr.bin/top/top.c
+++ b/usr.bin/top/top.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: top.c,v 1.67 2009/07/18 06:12:41 jmc Exp $ */
+/* $OpenBSD: top.c,v 1.68 2009/12/10 13:16:02 tedu Exp $ */
/*
* Top users/processes display for Unix
@@ -83,6 +83,7 @@ int old_system = No;
int old_threads = No;
int show_args = No;
pid_t hlpid = -1;
+int combine_cpus = 0;
#if Default_TOPN == Infinity
char topn_specified = No;
@@ -116,6 +117,7 @@ char topn_specified = No;
#define CMD_grep 20
#define CMD_add 21
#define CMD_hl 22
+#define CMD_cpus 23
static void
usage(void)
@@ -123,7 +125,7 @@ usage(void)
extern char *__progname;
fprintf(stderr,
- "usage: %s [-bCIinqSTu] [-d count] [-g string] [-o field] "
+ "usage: %s [-1bCIinqSTu] [-d count] [-g string] [-o field] "
"[-p pid] [-s time]\n\t[-U user] [number]\n",
__progname);
}
@@ -134,12 +136,14 @@ parseargs(int ac, char **av)
char *endp;
int i;
- while ((i = getopt(ac, av, "STICbinqus:d:p:U:o:g:")) != -1) {
+ while ((i = getopt(ac, av, "1STICbinqus:d:p:U:o:g:")) != -1) {
switch (i) {
+ case '1':
+ combine_cpus = 1;
+ break;
case 'C':
show_args = Yes;
break;
-
case 'u': /* toggle uid/username display */
do_unames = !do_unames;
break;
@@ -516,7 +520,7 @@ rundisplay(void)
int change, i;
struct pollfd pfd[1];
uid_t uid;
- static char command_chars[] = "\f qh?en#sdkriIuSopCTg+P";
+ static char command_chars[] = "\f qh?en#sdkriIuSopCTg+P1";
/*
* assume valid command unless told
@@ -899,7 +903,11 @@ rundisplay(void)
ps.command = NULL; /* grep */
hlpid = -1;
break;
-
+ case CMD_cpus:
+ combine_cpus = !combine_cpus;
+ max_topn = display_resize();
+ reset_display();
+ break;
default:
new_message(MT_standout, " BAD CASE IN SWITCH!");
putr();