Page MenuHomeFreeBSD

D37501.1784761131.diff
No OneTemporary

Size
3 KB
Referenced Files
None
Subscribers
None

D37501.1784761131.diff

Index: usr.bin/top/commands.h
===================================================================
--- usr.bin/top/commands.h
+++ usr.bin/top/commands.h
@@ -33,6 +33,7 @@
CMD_renice,
CMD_idletog,
CMD_user,
+ CMD_excludeusers,
CMD_selftog,
CMD_thrtog,
CMD_viewtog,
Index: usr.bin/top/commands.c
===================================================================
--- usr.bin/top/commands.c
+++ usr.bin/top/commands.c
@@ -79,6 +79,7 @@
{'T', "toggle the displaying of thread IDs", false, CMD_toggletid},
{'t', "toggle the display of this process", false, CMD_selftog},
{'u', "display processes for only one user (+ selects all users)", false, CMD_user},
+ {'x', "toggle exclude/include user list from/to displaying", false, CMD_excludeusers},
{'w', "toggle the display of swap use for each process", false, CMD_swaptog},
{'z', "toggle the displaying of the system idle process", false, CMD_kidletog},
{' ', "update the display", false, CMD_update},
Index: usr.bin/top/machine.h
===================================================================
--- usr.bin/top/machine.h
+++ usr.bin/top/machine.h
@@ -18,6 +18,8 @@
/* Log base 2 of 1024 is 10 (2^10 == 1024) */
#define LOG1024 10
+extern int excludeusers;
+
/*
* the statics struct is filled in by machine_init
*/
Index: usr.bin/top/machine.c
===================================================================
--- usr.bin/top/machine.c
+++ usr.bin/top/machine.c
@@ -863,10 +863,14 @@
/* skip proc. that don't belong to the selected JID */
continue;
- if (sel->uid[0] != -1 && !find_uid(pp->ki_ruid, sel->uid))
+ if (sel->uid[0] != -1 && !excludeusers && !find_uid(pp->ki_ruid, sel->uid))
/* skip proc. that don't belong to the selected UID */
continue;
+ if (sel->uid[0] != -1 && excludeusers && find_uid(pp->ki_ruid, sel->uid))
+ /* skip proc. that belong to the selected UID */
+ continue;
+
if (sel->pid != -1 && pp->ki_pid != sel->pid)
continue;
Index: usr.bin/top/top.1
===================================================================
--- usr.bin/top/top.1
+++ usr.bin/top/top.1
@@ -202,6 +202,11 @@
.Ar username .
This option currently only accepts usernames and will not understand
uid numbers.
+.It Fl x
+When using
+.Fl U ,
+hide processes owned by
+.Ar username .
.It Fl u
Do not map uid numbers to usernames.
Normally,
@@ -328,6 +333,10 @@
and
.Dq - ,
respectively.
+.It x
+Toggle show/hide processess beloging to a specific set of usernames set by
+the command
+.Dq u .
.It o
Change the order in which the display is sorted.
The sort key names include
Index: usr.bin/top/top.c
===================================================================
--- usr.bin/top/top.c
+++ usr.bin/top/top.c
@@ -55,6 +55,7 @@
static int fmt_flags = 0;
int show_args = false;
int pcpu_stats = false;
+int excludeusers = false;
/* signal handling routines */
static sigret_t leave(int);
@@ -121,6 +122,7 @@
{
for (size_t i = 0; i < TOP_MAX_UIDS; ++i)
ps.uid[i] = -1;
+ excludeusers = false;
}
static int
@@ -313,7 +315,7 @@
optind = 1;
}
- while ((i = getopt_long(ac, __DECONST(char * const *, av), "CSIHPabijJ:nquvzs:d:U:m:o:p:Ttw", longopts, NULL)) != EOF)
+ while ((i = getopt_long(ac, __DECONST(char * const *, av), "CSIHPabijJ:nquvzxs:d:U:m:o:p:Ttw", longopts, NULL)) != EOF)
{
switch(i)
{
@@ -459,6 +461,10 @@
ps.swap = 1;
break;
+ case 'x':
+ excludeusers = true;
+ break;
+
case 'z':
ps.kidle = !ps.kidle;
break;
@@ -992,6 +998,18 @@
no_command = true;
break;
+ case CMD_excludeusers:
+ if (ps.uid[0] == -1) {
+ new_message(MT_standout | MT_delayed,
+ "Empty user list. Use \"u\" to set the list");
+ } else {
+ excludeusers = !excludeusers;
+ new_message(MT_standout | MT_delayed, excludeusers ?
+ "Hiding users in user list" :
+ "Showing only users in user list");
+ }
+ break;
+
case CMD_thrtog:
ps.thread = !ps.thread;
new_message(MT_standout | MT_delayed,

File Metadata

Mime Type
text/plain
Expires
Wed, Jul 22, 10:58 PM (5 h, 36 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29232280
Default Alt Text
D37501.1784761131.diff (3 KB)

Event Timeline