diff options
author | Ted Unangst <tedu@cvs.openbsd.org> | 2005-12-04 23:10:07 +0000 |
---|---|---|
committer | Ted Unangst <tedu@cvs.openbsd.org> | 2005-12-04 23:10:07 +0000 |
commit | d2884319d2a5e750908f591a8f757ebf80f8d84d (patch) | |
tree | 6acf1872224cf26b5f6f59fb63275e9d92cc073d /usr.bin/top | |
parent | c97f71cbe005cae34f9db5673aea3b3492ccd7f1 (diff) |
support for toggling thread viewing.
ok brad, hints from jmc
Diffstat (limited to 'usr.bin/top')
-rw-r--r-- | usr.bin/top/commands.c | 3 | ||||
-rw-r--r-- | usr.bin/top/machine.c | 8 | ||||
-rw-r--r-- | usr.bin/top/machine.h | 3 | ||||
-rw-r--r-- | usr.bin/top/top.1 | 6 | ||||
-rw-r--r-- | usr.bin/top/top.c | 23 |
5 files changed, 33 insertions, 10 deletions
diff --git a/usr.bin/top/commands.c b/usr.bin/top/commands.c index 5d45c2f9c5e..b40fcdbe59b 100644 --- a/usr.bin/top/commands.c +++ b/usr.bin/top/commands.c @@ -1,4 +1,4 @@ -/* $OpenBSD: commands.c,v 1.18 2005/10/07 17:46:13 hshoexer Exp $ */ +/* $OpenBSD: commands.c,v 1.19 2005/12/04 23:10:06 tedu Exp $ */ /* * Top users/processes display for Unix @@ -100,6 +100,7 @@ show_help(void) "s - change number of seconds to delay between updates\n" "S - toggle the display of system processes\n" "u - display processes for only one user (+ selects all users)\n" + "T - toggle the display of threads\n" "C - toggle the display of the command line arguments\n" "\n\n", stdout); } diff --git a/usr.bin/top/machine.c b/usr.bin/top/machine.c index bf35b584712..a99a0330b4b 100644 --- a/usr.bin/top/machine.c +++ b/usr.bin/top/machine.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machine.c,v 1.49 2005/06/17 09:40:48 markus Exp $ */ +/* $OpenBSD: machine.c,v 1.50 2005/12/04 23:10:06 tedu Exp $ */ /*- * Copyright (c) 1994 Thorsten Lockert <tholo@sigmasoft.com> @@ -342,7 +342,7 @@ caddr_t get_process_info(struct system_info *si, struct process_select *sel, int (*compare) (const void *, const void *)) { - int show_idle, show_system, show_uid, show_pid; + int show_idle, show_system, show_threads, show_uid, show_pid; int total_procs, active_procs; struct kinfo_proc2 **prefp, *pp; @@ -363,6 +363,7 @@ get_process_info(struct system_info *si, struct process_select *sel, /* set up flags which define what we are going to select */ show_idle = sel->idle; show_system = sel->system; + show_threads = sel->threads; show_uid = sel->uid != (uid_t)-1; show_pid = sel->pid != (pid_t)-1; @@ -379,7 +380,8 @@ get_process_info(struct system_info *si, struct process_select *sel, * processes---these get ignored unless show_sysprocs is set. */ if (pp->p_stat != 0 && - (show_system || (pp->p_flag & P_SYSTEM) == 0)) { + (show_system || (pp->p_flag & P_SYSTEM) == 0) && + (show_threads || (pp->p_flag & P_THREAD) == 0)) { total_procs++; process_states[(unsigned char) pp->p_stat]++; if (pp->p_stat != SZOMB && diff --git a/usr.bin/top/machine.h b/usr.bin/top/machine.h index 4a7243cb108..cce60e2f106 100644 --- a/usr.bin/top/machine.h +++ b/usr.bin/top/machine.h @@ -1,4 +1,4 @@ -/* $OpenBSD: machine.h,v 1.13 2005/06/08 22:36:43 millert Exp $ */ +/* $OpenBSD: machine.h,v 1.14 2005/12/04 23:10:06 tedu Exp $ */ /* * Top users/processes display for Unix @@ -72,6 +72,7 @@ struct system_info { struct process_select { int idle; /* show idle processes */ int system; /* show system processes */ + int threads; /* show threads */ uid_t uid; /* only this uid (unless uid == -1) */ pid_t pid; /* only this pid (unless pid == -1) */ char *command;/* only this command (unless == NULL) */ diff --git a/usr.bin/top/top.1 b/usr.bin/top/top.1 index 48b710d5903..b54e7095d60 100644 --- a/usr.bin/top/top.1 +++ b/usr.bin/top/top.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: top.1,v 1.31 2005/09/06 23:30:33 jmc Exp $ +.\" $OpenBSD: top.1,v 1.32 2005/12/04 23:10:06 tedu Exp $ .\" .\" Copyright (c) 1997, Jason Downs. All rights reserved. .\" @@ -152,6 +152,10 @@ Set the delay between screen updates to seconds. The value may be fractional, to permit delays of less than 1 second. The default delay between updates is 5 seconds. +.It Fl T +Show process threads in the display. +Normally, only the main process is shown. +This option makes all threads visible. .It Fl U Ar username Show only those processes owned by .Ar username . diff --git a/usr.bin/top/top.c b/usr.bin/top/top.c index 411014a2617..39db4594a3b 100644 --- a/usr.bin/top/top.c +++ b/usr.bin/top/top.c @@ -1,4 +1,4 @@ -/* $OpenBSD: top.c,v 1.40 2005/06/17 09:40:48 markus Exp $ */ +/* $OpenBSD: top.c,v 1.41 2005/12/04 23:10:06 tedu Exp $ */ /* * Top users/processes display for Unix @@ -97,6 +97,7 @@ char *order_name = NULL; int topn = Default_TOPN; int no_command = Yes; int old_system = No; +int old_threads = No; int show_args = No; #if Default_TOPN == Infinity @@ -127,6 +128,7 @@ char topn_specified = No; #define CMD_order 16 #define CMD_pid 17 #define CMD_command 18 +#define CMD_threads 19 static void usage(void) @@ -134,7 +136,7 @@ usage(void) extern char *__progname; fprintf(stderr, - "usage: %s [-bIinqSu] [-d count] [-o field] [-p pid] [-s time] [-U username] [number]\n", + "usage: %s [-bIinqSTu] [-d count] [-o field] [-p pid] [-s time] [-U username] [number]\n", __progname); } @@ -144,7 +146,7 @@ parseargs(int ac, char **av) char *endp; int i; - while ((i = getopt(ac, av, "SIbinqus:d:p:U:o:")) != -1) { + while ((i = getopt(ac, av, "STIbinqus:d:p:U:o:")) != -1) { switch (i) { case 'u': /* toggle uid/username display */ do_unames = !do_unames; @@ -176,6 +178,11 @@ parseargs(int ac, char **av) old_system = Yes; break; + case 'T': /* show threads */ + ps.threads = Yes; + old_threads = Yes; + break; + case 'I': /* show idle processes */ ps.idle = !ps.idle; break; @@ -514,7 +521,7 @@ rundisplay(void) int change, i; struct pollfd pfd[1]; uid_t uid; - static char command_chars[] = "\f qh?en#sdkriIuSopC"; + static char command_chars[] = "\f qh?en#sdkriIuSopCT"; /* * assume valid command unless told @@ -853,6 +860,14 @@ rundisplay(void) case CMD_command: show_args = (show_args == No) ? Yes : No; break; + + case CMD_threads: + ps.threads = !ps.threads; + old_threads = ps.threads; + new_message(MT_standout | MT_delayed, + " %sisplaying threads.", + ps.threads ? "D" : "Not d"); + break; default: new_message(MT_standout, " BAD CASE IN SWITCH!"); |