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.
This commit is contained in:
parent
4c4eea9ffb
commit
f1ff637196
@ -841,11 +841,11 @@ get_process_info(struct system_info *si, struct process_select *sel,
|
||||
/* 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 process_select *sel,
|
||||
/* 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;
|
||||
|
||||
|
@ -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 + 2, "command chars size")
|
||||
|
||||
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');
|
||||
|
Loading…
x
Reference in New Issue
Block a user