svn commit: r334901 - head/usr.bin/top
Eitan Adler
eadler at FreeBSD.org
Sat Jun 9 23:08:03 UTC 2018
Author: eadler
Date: Sat Jun 9 23:08:02 2018
New Revision: 334901
URL: https://svnweb.freebsd.org/changeset/base/334901
Log:
top(1): handle specific pids better
When told to watch a specific pid, don't filter idle, system, or self
processes. The summary at the top will still flip correctly though.
Modified:
head/usr.bin/top/machine.c
head/usr.bin/top/top.c
Modified: head/usr.bin/top/machine.c
==============================================================================
--- head/usr.bin/top/machine.c Sat Jun 9 23:07:32 2018 (r334900)
+++ head/usr.bin/top/machine.c Sat Jun 9 23:08:02 2018 (r334901)
@@ -841,11 +841,11 @@ get_process_info(struct system_info *si, struct proces
/* not in use */
continue;
- if (!sel->self && pp->ki_pid == mypid)
+ if (!sel->self && pp->ki_pid == mypid && sel->pid == -1)
/* skip self */
continue;
- if (!sel->system && (pp->ki_flag & P_SYSTEM))
+ if (!sel->system && (pp->ki_flag & P_SYSTEM) && sel->pid == -1)
/* skip system process */
continue;
@@ -861,7 +861,7 @@ get_process_info(struct system_info *si, struct proces
/* skip zombies */
continue;
- if (!sel->kidle && pp->ki_tdflags & TDF_IDLETD)
+ if (!sel->kidle && pp->ki_tdflags & TDF_IDLETD && sel->pid == -1)
/* skip kernel idle process */
continue;
Modified: head/usr.bin/top/top.c
==============================================================================
--- head/usr.bin/top/top.c Sat Jun 9 23:07:32 2018 (r334900)
+++ head/usr.bin/top/top.c Sat Jun 9 23:08:02 2018 (r334901)
@@ -259,7 +259,6 @@ main(int argc, char *argv[])
char *order_name = NULL;
int order_index = 0;
fd_set readfds;
- char old_system = false;
static const char command_chars[] = "\f qh?en#sdkriIutHmSCajzPJwopT";
/* these defines enumerate the "strchr"s of the commands in command_chars */
@@ -381,7 +380,6 @@ _Static_assert(sizeof(command_chars) == CMD_toggletid
case 'S': /* show system processes */
ps.system = true;
- old_system = true;
break;
case 'I': /* show idle processes */
@@ -1086,7 +1084,6 @@ restart:
break;
case CMD_viewsys:
ps.system = !ps.system;
- old_system = ps.system;
break;
case CMD_showargs:
fmt_flags ^= FMT_SHOWARGS;
@@ -1193,7 +1190,6 @@ restart:
if (tempbuf2[0] == '+' &&
tempbuf2[1] == '\0') {
ps.pid = (pid_t)-1;
- ps.system = old_system;
} else {
unsigned long long num;
const char *errstr;
@@ -1206,10 +1202,7 @@ restart:
tempbuf2);
no_command = true;
} else {
- if (ps.system == false)
- old_system = false;
ps.pid = (pid_t)num;
- ps.system = true;
}
}
putchar('\r');
More information about the svn-src-all
mailing list