9d42a3ba0f
- add mising comment
61 lines
2.3 KiB
Plaintext
61 lines
2.3 KiB
Plaintext
$OpenBSD: patch-psinfo_c,v 1.2 2011/07/06 12:50:15 jasper Exp $
|
|
|
|
Adapt to new OpenBSD kinfo_proc API.
|
|
|
|
--- psinfo.c.orig Sun Mar 15 03:15:49 2009
|
|
+++ psinfo.c Wed Jul 6 14:41:49 2011
|
|
@@ -90,7 +90,11 @@ char *getProcessNameByProcessID(int pid)
|
|
{
|
|
int found;
|
|
kvm_t *kd;
|
|
+#if defined(__OpenBSD__)
|
|
struct kinfo_proc *givenproc;
|
|
+#else
|
|
+ struct kinfo_procs *givenproc;
|
|
+#endif
|
|
|
|
|
|
/* get kvm_t descriptor on /dev/mem */
|
|
@@ -103,7 +107,11 @@ char *getProcessNameByProcessID(int pid)
|
|
* get kinfo_proc structure from kernel for our pid.
|
|
* Since pids are had better be unique, we should only get one.
|
|
*/
|
|
+#if defined(__OpenBSD__)
|
|
+ givenproc = kvm_getprocs(kd, KERN_PROC_PID, pid, sizeof(struct kinfo_proc), &found);
|
|
+#else
|
|
givenproc = kvm_getprocs(kd, KERN_PROC_PID, pid, &found);
|
|
+#endif
|
|
|
|
switch (found) {
|
|
case 0:
|
|
@@ -117,6 +125,8 @@ char *getProcessNameByProcessID(int pid)
|
|
name = xstrdup(givenproc->ki_comm);
|
|
#elif defined(__DragonFly_version)
|
|
name = xstrdup(givenproc->kp_comm);
|
|
+ #elif defined(__OpenBSD__)
|
|
+ name = xstrdup(givenproc->p_comm);
|
|
# else
|
|
name = xstrdup(givenproc->kp_proc.p_comm);
|
|
#endif /* __FreeBSD__ */
|
|
@@ -249,10 +259,8 @@ float getProcessCPUPercentByProcessID(int pid)
|
|
}
|
|
#elif defined(USE_KVM)
|
|
{
|
|
- #if defined(__FreeBSD__) || defined(__DragonFly_version)
|
|
struct kinfo_proc *givenproc;
|
|
- #else
|
|
- struct kinfo_proc2 *givenproc;
|
|
+ #if !defined(__FreeBSD__) && !defined(__DragonFly_version)
|
|
struct nlist readnl[] = {{"_fscale"}, {NULL}};
|
|
#endif /* __FreeBSD__ or __DragonFly_version */
|
|
kvm_t *kd;
|
|
@@ -294,7 +302,7 @@ float getProcessCPUPercentByProcessID(int pid)
|
|
#if defined(__FreeBSD__) || defined(__DragonFly_version)
|
|
givenproc = kvm_getprocs(kd, KERN_PROC_PID, pid, &found);
|
|
#else
|
|
- givenproc = kvm_getproc2(kd, KERN_PROC_PID, pid, sizeof(struct kinfo_proc2), &found);
|
|
+ givenproc = kvm_getprocs(kd, KERN_PROC_PID, pid, sizeof(struct kinfo_proc), &found);
|
|
#endif /* __FreeBSD__ or __DragonFly_version */
|
|
|
|
switch (found) {
|