proc and p_runtime
David Rhodus
drhodus at catpa.com
Mon Nov 10 12:23:35 PST 2003
On Nov 10, 2003, at 3:15 PM, Peter Kadau wrote:
Hi !
Can anybody shed some light on the fate
of p_runtime (is in freebsd-4 in proc) ?
I tried to install kde3/gnome2 and both failed
in early stages (kdebase3 resp. glibtop2) because
of references to such members of proc.
I could deal with p_comm and friends but p_runtime ??
Sorry, if this doesn't fit here, but I searched the
archives (on shininglicense) to no avail.
Grepping through /usr/src/sys didn't help either.
Perhaps your looking for something like this ?
-DR
client-98# cat kde+ProcessList.c.diff
--- ProcessList.c.orig Wed Jul 30 00:23:10 2003
+++ ProcessList.c Wed Jul 30 18:59:32 2003
@@ -28,6 +28,9 @@
#include <stdlib.h>
#include <string.h>
#include <sys/param.h>
+#include <sys/proc.h>
+#include <sys/user.h>
+#include <sys/resourcevar.h>
#if __FreeBSD_version > 500015
#include <sys/priority.h>
#endif
@@ -108,7 +111,7 @@
* good idea. I never thought that the stability of UNIX could
get me
* into trouble! ;)
*/
- unsigned int userTime;
+ long userTime;
/*
* The number of 1/100 of a second the process has spend in
system space.
@@ -167,6 +170,7 @@
struct passwd* pwent;
int mib[4];
struct kinfo_proc p;
+ struct rusage pru;
size_t len;
if ((ps = findProcessInList(pid)) == 0)
@@ -209,7 +213,10 @@
#if __FreeBSD_version >= 500015
ps->userTime = p.ki_runtime / 10000;
#elif __FreeBSD_version >= 300000
- ps->userTime = p.kp_proc.p_runtime / 10000;
+ if (!getrusage(p.kp_proc.p_pid, &pru)) {
+ errx(1, "failed to get rusage info");
+ }
+ ps->userTime = pru.ru_utime.tv_usec / 10000; /*p_runtime /
10000;*/
#else
ps->userTime =
p.kp_proc.p_rtime.tv_sec*100+p.kp_proc.p_rtime.tv_usec/100;
#endif
@@ -234,7 +241,7 @@
p.kp_eproc.e_vm.vm_dsize +
p.kp_eproc.e_vm.vm_ssize) * getpagesize();
ps->vmRss = p.kp_eproc.e_vm.vm_rssize * getpagesize();
- strncpy(ps->name,p.kp_proc.p_comm ? p.kp_proc.p_comm : "????",
sizeof(ps->name));
+ strncpy(ps->name,p.kp_thread.td_comm ? p.kp_thread.td_comm :
"????", sizeof(ps->name));
strcpy(ps->status,(p.kp_proc.p_stat>=1)&&(p.kp_proc.p_stat<=5)?
statuses[p.kp_proc.p_stat-1]:"????");
#endif
client-98#
More information about the Kernel
mailing list