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:
Benoit Dejean
2015-06-21 20:23:27 +02:00
parent 4fb241097f
commit ca6cabe41d

View File

@@ -70,6 +70,7 @@ glibtop_get_proclist_p (glibtop *server, glibtop_proclist *buf,
glibtop_proc_state procstate;
size_t len;
unsigned int i;
pid_t prev;
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;
/* 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) {
case GLIBTOP_KERN_PROC_ALL:
break;