[Mono-dev] Implement stuff to make process name lookup work
Robert Nagy
robert at openbsd.org
Fri Apr 2 21:00:06 EDT 2010
Implement get_processname_from_proc() for OpenBSD
Index: io-layer/processes.c
===================================================================
--- io-layer/processes.c (revision 154749)
+++ io-layer/processes.c (working copy)
@@ -2153,10 +2153,12 @@
static gchar *get_process_name_from_proc (pid_t pid)
{
- gchar *filename = NULL;
gchar *ret = NULL;
+#if !defined(__OpenBSD__)
gchar buf[256];
+ gchar *filename = NULL;
FILE *fp;
+#endif
#if defined(PLATFORM_SOLARIS)
filename = g_strdup_printf ("/proc/%d/psinfo", pid);
@@ -2172,6 +2174,22 @@
fclose (fp);
}
g_free (filename);
+#elif defined(__OpenBSD__)
+ int res;
+ int mib [6];
+ struct kinfo_proc2 result;
+ size_t data_len = sizeof (struct kinfo_proc2);
+
+ mib [0] = CTL_KERN;
+ mib [1] = KERN_PROC2;
+ mib [2] = KERN_PROC_PID;
+ mib [3] = pid;
+ mib [4] = sizeof(struct kinfo_proc2);
+ mib [5] = 400; /* XXX */
+
+ res = sysctl (mib, 6, &result, &data_len, NULL, 0);
+ if (res == 0)
+ ret = g_strdup (result.p_comm);
#elif defined(PLATFORM_MACOSX)
memset (buf, '\0', sizeof(buf));
proc_name (pid, buf, sizeof(buf));
@@ -2242,7 +2260,9 @@
gchar *procname_ext = NULL;
glong len;
gsize bytes;
+#if !defined(__OpenBSD__)
FILE *fp;
+#endif
GSList *mods = NULL;
WapiProcModule *found_module;
guint32 count;
@@ -2285,6 +2305,14 @@
#ifdef PLATFORM_MACOSX
{
mods = load_modules ();
+#elif defined(__OpenBSD__)
+ {
+ if (module == NULL && base == TRUE) {
+ procname_ext = get_process_name_from_proc (pid);
+ } else {
+ g_free (proc_name);
+ return(0);
+ }
#else
if ((fp = open_process_map (pid, "r")) == NULL) {
if (errno == EACCES && module == NULL && base == TRUE) {
More information about the Mono-devel-list
mailing list