Subject: | Compile fails under OpenBSD 5.1 |
Proc::ProcessTable 0.45 fails to compile under OpenBSD 5.1. I am no
OpenBSD guru, but this appears to be because the obsolete kvm_getproc2()
and kvm_getargv2() subroutines were removed in that release.
Fortunately, kvm_getprocs() and kvm_getargv() exist, with the same
functionality and signatures, so all that appears to be needed to get
you going is an '#ifndef kinfo_proc2' in os/OpenBSD.c to fix things up.
The attached patch does this, and also silences a cast warning.
CAVEAT: my experience with OpenBSD does not go back further than 5.0,
and the '#ifndef' trick was cribbed from the 5.0 kvm.h file. The patch
works for me under 5.0 and 5.1, but I have no idea about other version.
Subject: | Proc-ProcessTable-OpenBSD.patch |
--- os/OpenBSD.old Thu May 25 15:14:05 2006
+++ os/OpenBSD.c Wed May 9 10:34:27 2012
@@ -24,6 +24,15 @@
#include <time.h>
#include <unistd.h>
+/* The following needed with OpenBSD 5.1. In 5.0 it was in sys/sysctl.h
+ * and kvm.h */
+
+#ifndef kinfo_proc2
+#define kinfo_proc2 kinfo_proc
+#define kvm_getproc2 kvm_getprocs
+#define kvm_getargv2 kvm_getargv
+#endif
+
/* No need for the procstat structure since we don't use /proc */
/* We need to pass in a cap for ignore, lower for store on object */
@@ -124,7 +133,7 @@
}
/* arguments */
- cmndline[0] = NULL;
+ cmndline[0] = '\0';
pargv = kvm_getargv2(kd, (const struct kinfo_proc2 *) &(procs[i]), 0);
if (pargv) {
argcount = 0;