Use correct values for the `state' field.

1998-10-03  Martin Baulig  <martin@home-of-linux.org>

	* procstate.c (glibtop_get_procstate_s): Use correct values for
	the `state' field.

	* proclist.c (glibtop_get_proclist_p): Honor the GLIBTOP_EXCLUDE_IDLE
	and GLIBTOP_EXCLUDE_SYSTEM flags of the `which' parameter.
This commit is contained in:
Martin Baulig
1998-10-03 02:15:55 +00:00
committed by Martin Baulig
parent 0289863af0
commit a444c860d2
3 changed files with 42 additions and 9 deletions

View File

@@ -1,3 +1,11 @@
1998-10-03 Martin Baulig <martin@home-of-linux.org>
* procstate.c (glibtop_get_procstate_s): Use correct values for
the `state' field.
* proclist.c (glibtop_get_proclist_p): Honor the GLIBTOP_EXCLUDE_IDLE
and GLIBTOP_EXCLUDE_SYSTEM flags of the `which' parameter.
1998-08-24 Martin Baulig <martin@home-of-linux.org>
* *.c (glibtop_init_p): Using correct `(1 << GLIBTOP_SYSDPES_*)'.

View File

@@ -58,12 +58,12 @@ glibtop_init_proclist_p (glibtop *server)
unsigned *
glibtop_get_proclist_p (glibtop *server, glibtop_proclist *buf,
int64_t which, int64_t arg)
int64_t real_which, int64_t arg)
{
struct kinfo_proc *pinfo;
unsigned *pids = NULL;
int count;
int i;
int which, count;
int i,j;
glibtop_init_p (server, (1 << GLIBTOP_SYSDEPS_PROCLIST), 0);
@@ -71,7 +71,7 @@ glibtop_get_proclist_p (glibtop *server, glibtop_proclist *buf,
glibtop_suid_enter (server);
which &= GLIBTOP_KERN_PROC_MASK;
which = (int)(real_which & GLIBTOP_KERN_PROC_MASK);
/* Get the process data */
pinfo = kvm_getprocs (server->machine.kd, which, arg, &count);
@@ -86,13 +86,19 @@ glibtop_get_proclist_p (glibtop *server, glibtop_proclist *buf,
* Same as malloc is pids is NULL, which it is. */
pids = glibtop_realloc_r (server, pids, count * sizeof (unsigned));
/* Copy the pids over to this chain */
for (i=0; i < count; i++) {
pids [i] = (unsigned) pinfo[i].kp_proc.p_pid;
for (i=j=0; i < count; i++) {
if ((real_which & GLIBTOP_EXCLUDE_IDLE) &&
(pinfo[i].kp_proc.p_stat != SRUN))
continue;
else if ((real_which & GLIBTOP_EXCLUDE_SYSTEM) &&
(pinfo[i].kp_eproc.e_pcred.p_ruid == 0))
continue;
pids [j++] = (unsigned) pinfo[i].kp_proc.p_pid;
} /* end for */
/* Set the fields in buf */
buf->number = count;
buf->number = j;
buf->size = sizeof (unsigned);
buf->total = count * sizeof (unsigned);
buf->total = j * sizeof (unsigned);
buf->flags = _glibtop_sysdeps_proclist;
return pids;
}

View File

@@ -68,7 +68,26 @@ glibtop_get_proc_state_p (glibtop *server,
buf->uid = pinfo [0].kp_eproc.e_pcred.p_svuid;
buf->gid = pinfo [0].kp_eproc.e_pcred.p_svgid;
buf->state = pinfo [0].kp_proc.p_stat;
switch (pinfo [0].kp_proc.p_stat) {
case SIDL:
buf->state = 'I';
break;
case SRUN:
buf->state = 'R';
break;
case SSLEEP:
buf->state = 'S';
break;
case SSTOP:
buf->state = 'T';
break;
case SZOMB:
buf->state = 'Z';
break;
default:
buf->state = '?';
break;
}
/* Set the flags for the data we're about to return*/
buf->flags = _glibtop_sysdeps_proc_state;