diff --git a/sysdeps/linux/ChangeLog b/sysdeps/linux/ChangeLog index 3cdeabda..4e794c35 100644 --- a/sysdeps/linux/ChangeLog +++ b/sysdeps/linux/ChangeLog @@ -1,3 +1,8 @@ +1998-10-02 Martin Baulig + + * proclist.c (glibtop_init_proclist_s): You can now also use the + `GLIBTOP_EXCLUDE_*' flags for the `which' parameter. + 1998-10-01 Martin Baulig * proclist.c (glibtop_init_proclist_s): Honor the `which' parameter diff --git a/sysdeps/linux/proclist.c b/sysdeps/linux/proclist.c index d31c7379..502f81bd 100644 --- a/sysdeps/linux/proclist.c +++ b/sysdeps/linux/proclist.c @@ -21,9 +21,11 @@ #include #include -#include #include +#include +#include + #include #include #include @@ -67,10 +69,12 @@ glibtop_get_proclist_s (glibtop *server, glibtop_proclist *buf, unsigned count, total, pid; unsigned pids [BLOCK_COUNT], *pids_chain = NULL; unsigned pids_size = 0, pids_offset = 0, new_size; - glibtop_proc_uid procuid; struct stat statb; int len, i, ok; + glibtop_proc_uid procuid; + glibtop_proc_state procstate; + glibtop_init_s (&server, GLIBTOP_SYSDEPS_PROCLIST, 0); memset (buf, 0, sizeof (glibtop_proclist)); @@ -102,7 +106,7 @@ glibtop_get_proclist_s (glibtop *server, glibtop_proclist *buf, if (!S_ISDIR (statb.st_mode)) continue; - switch (which) { + switch (which & GLIBTOP_KERN_PROC_MASK) { case GLIBTOP_KERN_PROC_ALL: break; case GLIBTOP_KERN_PROC_PID: @@ -143,6 +147,24 @@ glibtop_get_proclist_s (glibtop *server, glibtop_proclist *buf, break; } + if (which & GLIBTOP_EXCLUDE_NOTTY) { + glibtop_get_proc_uid_s (server, &procuid, pid); + if (procuid.flags & (1 << GLIBTOP_PROC_UID_TTY)) + if (procuid.tty == -1) continue; + } + + if (which & GLIBTOP_EXCLUDE_IDLE) { + glibtop_get_proc_state_s (server, &procstate, pid); + if (procstate.flags & (1 << GLIBTOP_PROC_STATE_STATE)) + if (procstate.state != 'R') continue; + } + + if (which & GLIBTOP_EXCLUDE_SYSTEM) { + glibtop_get_proc_uid_s (server, &procuid, pid); + if (procuid.flags & (1 << GLIBTOP_PROC_UID_UID)) + if (procuid.uid == 0) continue; + } + /* Fine. Now we first try to store it in pids. If this buffer is * full, we copy it to the pids_chain. */