Honor the `which' parameter to select which processes to fetch.

1998-10-01  Martin Baulig  <baulig@Stud.Informatik.uni-trier.de>

	* proclist.c (glibtop_init_proclist_s): Honor the `which' parameter
	to select which processes to fetch.
This commit is contained in:
Martin Baulig
1998-10-01 17:04:48 +00:00
committed by Martin Baulig
parent 23cdbd5336
commit 93568304b0
2 changed files with 48 additions and 0 deletions

View File

@@ -1,3 +1,8 @@
1998-10-01 Martin Baulig <baulig@Stud.Informatik.uni-trier.de>
* proclist.c (glibtop_init_proclist_s): Honor the `which' parameter
to select which processes to fetch.
1998-09-12 Martin Baulig <martin@home-of-linux.org> 1998-09-12 Martin Baulig <martin@home-of-linux.org>
* sysinfo.c: New file. * sysinfo.c: New file.

View File

@@ -21,6 +21,7 @@
#include <config.h> #include <config.h>
#include <glibtop/xmalloc.h> #include <glibtop/xmalloc.h>
#include <glibtop/procuid.h>
#include <glibtop/proclist.h> #include <glibtop/proclist.h>
#include <sys/stat.h> #include <sys/stat.h>
@@ -66,6 +67,7 @@ glibtop_get_proclist_s (glibtop *server, glibtop_proclist *buf,
unsigned count, total, pid; unsigned count, total, pid;
unsigned pids [BLOCK_COUNT], *pids_chain = NULL; unsigned pids [BLOCK_COUNT], *pids_chain = NULL;
unsigned pids_size = 0, pids_offset = 0, new_size; unsigned pids_size = 0, pids_offset = 0, new_size;
glibtop_proc_uid procuid;
struct stat statb; struct stat statb;
int len, i, ok; int len, i, ok;
@@ -100,6 +102,47 @@ glibtop_get_proclist_s (glibtop *server, glibtop_proclist *buf,
if (!S_ISDIR (statb.st_mode)) continue; if (!S_ISDIR (statb.st_mode)) continue;
switch (which) {
case GLIBTOP_KERN_PROC_ALL:
break;
case GLIBTOP_KERN_PROC_PID:
if ((unsigned) arg != pid)
continue;
break;
case GLIBTOP_KERN_PROC_UID:
if ((uid_t) arg != statb.st_uid)
continue;
break;
case GLIBTOP_KERN_PROC_PGRP:
/* Do you really, really need this ? */
glibtop_get_proc_uid_s (server, &procuid, pid);
if (procuid.flags & (1 << GLIBTOP_PROC_UID_PGRP))
if ((int) arg != procuid.pgrp)
continue;
break;
case GLIBTOP_KERN_PROC_SESSION:
/* Do you really, really need this ? */
glibtop_get_proc_uid_s (server, &procuid, pid);
if (procuid.flags & (1 << GLIBTOP_PROC_UID_SESSION))
if ((int) arg != procuid.session)
continue;
break;
case GLIBTOP_KERN_PROC_TTY:
/* Do you really, really need this ? */
glibtop_get_proc_uid_s (server, &procuid, pid);
if (procuid.flags & (1 << GLIBTOP_PROC_UID_TTY))
if ((int) arg != procuid.tty)
continue;
break;
case GLIBTOP_KERN_PROC_RUID:
/* Do you really, really need this ? */
glibtop_get_proc_uid_s (server, &procuid, pid);
if (procuid.flags & (1 << GLIBTOP_PROC_UID_EUID))
if ((int) arg != procuid.euid)
continue;
break;
}
/* Fine. Now we first try to store it in pids. If this buffer is /* Fine. Now we first try to store it in pids. If this buffer is
* full, we copy it to the pids_chain. */ * full, we copy it to the pids_chain. */