For processes with threads, only reports the pid once.
On my system, this brings proclist's output from +300 to 72.
This commit is contained in:
@@ -70,6 +70,7 @@ glibtop_get_proclist_p (glibtop *server, glibtop_proclist *buf,
|
|||||||
glibtop_proc_state procstate;
|
glibtop_proc_state procstate;
|
||||||
size_t len;
|
size_t len;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
pid_t prev;
|
||||||
|
|
||||||
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROCLIST), 0);
|
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROCLIST), 0);
|
||||||
|
|
||||||
@@ -97,6 +98,17 @@ glibtop_get_proclist_p (glibtop *server, glibtop_proclist *buf,
|
|||||||
|
|
||||||
pid = (pid_t) pinfo[i].ki_pid;
|
pid = (pid_t) pinfo[i].ki_pid;
|
||||||
|
|
||||||
|
/* If a process has many threads, kern.proc.all reports multiple
|
||||||
|
times the same pid. So don't look twice at the same pid.
|
||||||
|
FIXME?: not sure that kern.proc.all reports a partially sorted
|
||||||
|
list (all pid/threads grouped).
|
||||||
|
*/
|
||||||
|
if (i > 0 && pid == prev) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
prev = pid;
|
||||||
|
|
||||||
switch (which & GLIBTOP_KERN_PROC_MASK) {
|
switch (which & GLIBTOP_KERN_PROC_MASK) {
|
||||||
case GLIBTOP_KERN_PROC_ALL:
|
case GLIBTOP_KERN_PROC_ALL:
|
||||||
break;
|
break;
|
||||||
|
Reference in New Issue
Block a user