b47270d725
sem_timedwait()
136 lines
3.4 KiB
Plaintext
136 lines
3.4 KiB
Plaintext
$OpenBSD: patch-mono_utils_mono-proclib_c,v 1.12 2012/04/13 11:51:49 robert Exp $
|
|
--- mono/utils/mono-proclib.c.orig Mon Dec 19 22:10:27 2011
|
|
+++ mono/utils/mono-proclib.c Tue Mar 20 22:40:12 2012
|
|
@@ -25,17 +25,17 @@
|
|
#ifdef HAVE_SYS_USER_H
|
|
#include <sys/user.h>
|
|
#endif
|
|
-#ifdef HAVE_STRUCT_KINFO_PROC_KP_PROC
|
|
-# ifdef KERN_PROC2
|
|
+#if defined(__OpenBSD__)
|
|
# define kinfo_pid_member p_pid
|
|
# define kinfo_name_member p_comm
|
|
-# else
|
|
+#else
|
|
+# 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
|
|
-#else
|
|
-#define kinfo_pid_member ki_pid
|
|
-#define kinfo_name_member ki_comm
|
|
#endif
|
|
#define USE_SYSCTL 1
|
|
#endif
|
|
@@ -52,15 +52,13 @@ mono_process_list (int *size)
|
|
{
|
|
#if USE_SYSCTL
|
|
int res, i;
|
|
-#ifdef KERN_PROC2
|
|
+#if defined(__OpenBSD__)
|
|
int mib [6];
|
|
- size_t data_len = sizeof (struct kinfo_proc2) * 400;
|
|
- struct kinfo_proc2 *processes = malloc (data_len);
|
|
#else
|
|
int mib [4];
|
|
+#endif
|
|
size_t data_len = sizeof (struct kinfo_proc) * 400;
|
|
struct kinfo_proc *processes = malloc (data_len);
|
|
-#endif /* KERN_PROC2 */
|
|
void **buf = NULL;
|
|
|
|
if (size)
|
|
@@ -68,33 +66,22 @@ mono_process_list (int *size)
|
|
if (!processes)
|
|
return NULL;
|
|
|
|
-#ifdef KERN_PROC2
|
|
mib [0] = CTL_KERN;
|
|
- mib [1] = KERN_PROC2;
|
|
+ mib [1] = KERN_PROC;
|
|
mib [2] = KERN_PROC_ALL;
|
|
mib [3] = 0;
|
|
- mib [4] = sizeof(struct kinfo_proc2);
|
|
+#if defined(__OpenBSD__)
|
|
+ mib [4] = sizeof(struct kinfo_proc);
|
|
mib [5] = 400; /* XXX */
|
|
+#endif
|
|
|
|
- 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 */
|
|
+ res = sysctl (mib, (sizeof(mib) / sizeof(mib[0])), processes, &data_len, NULL, 0);
|
|
|
|
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);
|
|
@@ -188,42 +175,30 @@ mono_process_get_name (gpointer pid, char *buf, int le
|
|
{
|
|
#if USE_SYSCTL
|
|
int res;
|
|
-#ifdef KERN_PROC2
|
|
+#if defined(__OpenBSD__)
|
|
int mib [6];
|
|
- size_t data_len = sizeof (struct kinfo_proc2);
|
|
- struct kinfo_proc2 processi;
|
|
#else
|
|
int mib [4];
|
|
+#endif
|
|
size_t data_len = sizeof (struct kinfo_proc);
|
|
struct kinfo_proc processi;
|
|
-#endif /* KERN_PROC2 */
|
|
|
|
memset (buf, 0, len);
|
|
|
|
-#ifdef KERN_PROC2
|
|
mib [0] = CTL_KERN;
|
|
- mib [1] = KERN_PROC2;
|
|
+ mib [1] = KERN_PROC;
|
|
mib [2] = KERN_PROC_PID;
|
|
mib [3] = GPOINTER_TO_UINT (pid);
|
|
- mib [4] = sizeof(struct kinfo_proc2);
|
|
+#if defined(__OpenBSD__)
|
|
+ mib [4] = sizeof(struct kinfo_proc);
|
|
mib [5] = 400; /* XXX */
|
|
+#endif
|
|
|
|
- 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);
|
|
+ res = sysctl (mib, (sizeof(mib) / sizeof(mib[0])), &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
|