Mon Nov 10 17:38:41 CET 2008 Paolo Molaro <lupus@ximian.com>
authorPaolo Molaro <lupus@oddwiz.org>
Mon, 10 Nov 2008 16:41:54 +0000 (16:41 -0000)
committerPaolo Molaro <lupus@oddwiz.org>
Mon, 10 Nov 2008 16:41:54 +0000 (16:41 -0000)
* mono-proclib.c: adapt code for FreeBSD and hopefully other BSD
systems.

svn path=/trunk/mono/; revision=118385

mono/utils/ChangeLog
mono/utils/mono-proclib.c

index 16e813f408cc8a259cc82cc3fa7b69abe2a98cbb..58ba9f557b97ff706f21d856edb2085465f8fc75 100644 (file)
@@ -1,4 +1,9 @@
 
+Mon Nov 10 17:38:41 CET 2008 Paolo Molaro <lupus@ximian.com>
+
+       * mono-proclib.c: adapt code for FreeBSD and hopefully other BSD
+       systems.
+
 Mon Nov 10 17:27:01 CET 2008 Paolo Molaro <lupus@ximian.com>
 
        * mono-proclib.c, mono-proclib.h: added elapsed time and parent pid.
index e01d9b0a7851f07b92554f24b8dc9129754d25bd..c3fd5454e2e15c4aa3bd979cf0e70c65270ec458 100644 (file)
 #include <sys/types.h>
 #include <sys/sysctl.h>
 #include <sys/proc.h>
+#ifdef HAVE_SYS_USER_H
+#include <sys/user.h>
+#endif
+#ifdef HAVE_STRUCT_KINFO_PROC_KP_PROC
+#define kinfo_pid_member kp_proc.p_pid
+#define kinfo_name_member kp_proc.p_comm
+#else
+#define kinfo_pid_member ki_pid
+#define kinfo_name_member ki_comm
+#endif
 #define USE_SYSCTL 1
 #endif
 
@@ -55,7 +65,7 @@ mono_process_list (int *size)
        res = data_len/sizeof (struct kinfo_proc);
        buf = g_realloc (buf, res * sizeof (void*));
        for (i = 0; i < res; ++i)
-               buf [i] = GINT_TO_POINTER (processes [i].kp_proc.p_pid);
+               buf [i] = GINT_TO_POINTER (processes [i].kinfo_pid_member);
        free (processes);
        if (size)
                *size = res;
@@ -162,7 +172,7 @@ mono_process_get_name (gpointer pid, char *buf, int len)
        if (res < 0 || data_len != sizeof (struct kinfo_proc)) {
                return buf;
        }
-       strncpy (buf, processi.kp_proc.p_comm, len - 1);
+       strncpy (buf, processi.kinfo_name_member, len - 1);
        return buf;
 #else
        char fname [128];