- unbreak after KERN_PROC2 changes
reads ok to sthen@
This commit is contained in:
parent
d82b063c3a
commit
1ba29b9f05
@ -1,4 +1,4 @@
|
||||
# $OpenBSD: Makefile,v 1.15 2009/12/17 14:00:34 ajacoutot Exp $
|
||||
# $OpenBSD: Makefile,v 1.16 2010/01/19 15:07:01 jasper Exp $
|
||||
|
||||
# sync with net/avahi,-mono
|
||||
ONLY_FOR_ARCHS= amd64 i386 powerpc # arm
|
||||
@ -6,7 +6,7 @@ ONLY_FOR_ARCHS= amd64 i386 powerpc # arm
|
||||
COMMENT= cross platform, open source .NET developement framework
|
||||
|
||||
DISTNAME= mono-2.5
|
||||
PKGNAME= ${DISTNAME}p0
|
||||
PKGNAME= ${DISTNAME}p1
|
||||
|
||||
CATEGORIES= lang devel
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
$OpenBSD: patch-mono_utils_mono-proclib_c,v 1.1 2009/09/06 07:25:27 ajacoutot Exp $
|
||||
--- mono/utils/mono-proclib.c.orig Sun Aug 23 12:22:41 2009
|
||||
+++ mono/utils/mono-proclib.c Sun Aug 23 12:22:52 2009
|
||||
$OpenBSD: patch-mono_utils_mono-proclib_c,v 1.2 2010/01/19 15:07:01 jasper Exp $
|
||||
--- mono/utils/mono-proclib.c.orig Sat Aug 15 03:03:11 2009
|
||||
+++ mono/utils/mono-proclib.c Tue Jan 19 07:11:00 2010
|
||||
@@ -13,6 +13,9 @@
|
||||
#endif
|
||||
|
||||
@ -11,3 +11,102 @@ $OpenBSD: patch-mono_utils_mono-proclib_c,v 1.1 2009/09/06 07:25:27 ajacoutot Ex
|
||||
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
|
||||
#include <sys/types.h>
|
||||
#include <sys/sysctl.h>
|
||||
@@ -41,9 +44,14 @@ gpointer*
|
||||
mono_process_list (int *size)
|
||||
{
|
||||
#if USE_SYSCTL
|
||||
- int mib [4];
|
||||
int res, i;
|
||||
+#ifdef KERN_PROC2
|
||||
+ int mib [6];
|
||||
+ size_t data_len = sizeof (struct kinfo_proc2) * 400;
|
||||
+#else
|
||||
+ int mib [4];
|
||||
size_t data_len = sizeof (struct kinfo_proc) * 400;
|
||||
+#endif /* KERN_PROC2 */
|
||||
struct kinfo_proc *processes = malloc (data_len);
|
||||
void **buf = NULL;
|
||||
|
||||
@@ -52,17 +60,34 @@ mono_process_list (int *size)
|
||||
if (!processes)
|
||||
return NULL;
|
||||
|
||||
+#ifdef KERN_PROC2
|
||||
mib [0] = CTL_KERN;
|
||||
+ mib [1] = KERN_PROC2;
|
||||
+ mib [2] = KERN_PROC_ALL;
|
||||
+ mib [3] = 0;
|
||||
+ mib [4] = sizeof(struct kinfo_proc2);
|
||||
+ mib [5] = 400; /* XXX */
|
||||
+
|
||||
+ res = sysctl (mib, 6, processes, &data_len, NULL, 0);
|
||||
+#else
|
||||
+ mib [0] = CTL_KERN;
|
||||
mib [1] = KERN_PROC;
|
||||
mib [2] = KERN_PROC_ALL;
|
||||
mib [3] = 0;
|
||||
|
||||
res = sysctl (mib, 4, processes, &data_len, NULL, 0);
|
||||
+#endif /* KERN_PROC2 */
|
||||
+
|
||||
if (res < 0) {
|
||||
free (processes);
|
||||
return NULL;
|
||||
}
|
||||
+
|
||||
+#ifdef KERN_PROC2
|
||||
+ res = data_len/sizeof (struct kinfo_proc2);
|
||||
+#else
|
||||
res = data_len/sizeof (struct kinfo_proc);
|
||||
+#endif /* KERN_PROC2 */
|
||||
buf = g_realloc (buf, res * sizeof (void*));
|
||||
for (i = 0; i < res; ++i)
|
||||
buf [i] = GINT_TO_POINTER (processes [i].kinfo_pid_member);
|
||||
@@ -155,23 +180,45 @@ char*
|
||||
mono_process_get_name (gpointer pid, char *buf, int len)
|
||||
{
|
||||
#if USE_SYSCTL
|
||||
- int mib [4];
|
||||
int res;
|
||||
char *p;
|
||||
+#ifdef KERN_PROC2
|
||||
+ int mib [6];
|
||||
+ size_t data_len = sizeof (struct kinfo_proc2);
|
||||
+#else
|
||||
+ int mib [4];
|
||||
size_t data_len = sizeof (struct kinfo_proc);
|
||||
+#endif /* KERN_PROC2 */
|
||||
struct kinfo_proc processi;
|
||||
|
||||
memset (buf, 0, len);
|
||||
|
||||
+#ifdef KERN_PROC2
|
||||
mib [0] = CTL_KERN;
|
||||
+ mib [1] = KERN_PROC2;
|
||||
+ mib [2] = KERN_PROC_PID;
|
||||
+ mib [3] = GPOINTER_TO_UINT (pid);
|
||||
+ mib [4] = sizeof(struct kinfo_proc2);
|
||||
+ mib [5] = 400; /* XXX */
|
||||
+
|
||||
+ res = sysctl (mib, 6, &processi, &data_len, NULL, 0);
|
||||
+
|
||||
+ if (res < 0 || data_len != sizeof (struct kinfo_proc2)) {
|
||||
+ return buf;
|
||||
+ }
|
||||
+#else
|
||||
+ mib [0] = CTL_KERN;
|
||||
mib [1] = KERN_PROC;
|
||||
mib [2] = KERN_PROC_PID;
|
||||
mib [3] = GPOINTER_TO_UINT (pid);
|
||||
-
|
||||
+
|
||||
res = sysctl (mib, 4, &processi, &data_len, NULL, 0);
|
||||
+
|
||||
if (res < 0 || data_len != sizeof (struct kinfo_proc)) {
|
||||
return buf;
|
||||
}
|
||||
+#endif /* KERN_PROC2 */
|
||||
+
|
||||
strncpy (buf, processi.kinfo_name_member, len - 1);
|
||||
return buf;
|
||||
#else
|
||||
|
Loading…
Reference in New Issue
Block a user