diff --git a/top/top.1 b/top/top.1 index d6b35cfd..ae393fa7 100644 --- a/top/top.1 +++ b/top/top.1 @@ -381,6 +381,9 @@ Display only processes with a user id or user name matching that given. The '\-u' option matches on \fI effective\fR user whereas the '\-U' option matches on\fI any\fR user (real, effective, saved, or filesystem). +Prepending an exclamation point ('!') to the user id or name instucts top to +display only processes with users not matching the one provided. + The 'p', 'u' and 'U' \*(COs are mutually exclusive. .TP 5 @@ -1296,8 +1299,10 @@ matches on\fB any\fR user (real, effective, saved, or filesystem). Thereafter, in that \*(TW only matching users will be shown, or possibly no processes will be shown. -Different \*(TWs can can be used to filter different users. +Prepending an exclamation point ('!') to the user id or name instucts top +to display only processes with users not matching the one provided. +Different \*(TWs can can be used to filter different users. Later, if you wish to monitor all tasks again in the \*(CW, re-issue this command but just press at the prompt. diff --git a/top/top.c b/top/top.c index a21cf770..95f7da80 100644 --- a/top/top.c +++ b/top/top.c @@ -1218,8 +1218,10 @@ static const char *user_certify (WIN_t *q, const char *str, char typ) { uid_t num; q->usrseltyp = 0; + q->usrselflg = 1; Monpidsidx = 0; if (*str) { + if ('!' == *str) { ++str; q->usrselflg = 0; } num = (uid_t)strtoul(str, &endp, 0); if ('\0' == *endp) { pwd = getpwuid(num); @@ -1247,19 +1249,19 @@ static const char *user_certify (WIN_t *q, const char *str, char typ) { static inline int user_matched (WIN_t *q, const proc_t *p) { switch(q->usrseltyp) { case 0: // uid selection inactive - return 1; + return q->usrselflg; case 'U': // match any uid - if (p->ruid == q->usrseluid) return 1; - if (p->suid == q->usrseluid) return 1; - if (p->fuid == q->usrseluid) return 1; + if (p->ruid == q->usrseluid) return q->usrselflg; + if (p->suid == q->usrseluid) return q->usrselflg; + if (p->fuid == q->usrseluid) return q->usrselflg; // fall through... case 'u': // match effective uid - if (p->euid == q->usrseluid) return 1; + if (p->euid == q->usrseluid) return q->usrselflg; // fall through... - default: // no match, don't display + default: // no match... ; } - return 0; + return !q->usrselflg; } // end: user_matched /*###### Basic Formatting support ######################################*/ diff --git a/top/top.h b/top/top.h index b6b04469..381594bf 100644 --- a/top/top.h +++ b/top/top.h @@ -371,6 +371,7 @@ typedef struct WIN_t { varcolsz, // max length of variable width column(s) usrseluid, // validated uid for 'u/U' user selection usrseltyp, // the basis for matching above uid + usrselflg, // flag denoting include/exclude matches hdrcaplen; // column header xtra caps len, if any char capclr_sum [CLRBUFSIZ], // terminfo strings built from capclr_msg [CLRBUFSIZ], // RCW_t colors (& rebuilt too),