static mono_once_t process_current_once=MONO_ONCE_INIT;
static gpointer current_process=NULL;
+static char *cli_launcher;
static mono_once_t process_ops_once=MONO_ONCE_INIT;
* them using the same mono binary that started us.
*/
if (is_managed_binary (prog)) {
- gunichar2 *newapp, *newcmd;
+ gunichar2 *newapp = NULL, *newcmd;
gsize bytes_ignored;
- newapp = mono_unicode_from_external ("mono", &bytes_ignored);
+ if (cli_launcher)
+ newapp = mono_unicode_from_external (cli_launcher, &bytes_ignored);
+ else
+ newapp = mono_unicode_from_external ("mono", &bytes_ignored);
if (newapp != NULL) {
if (appname != NULL) {
gboolean done;
size_t proclength, size;
#if defined(__OpenBSD__)
- struct kinfo_proc2 *result;
+ struct kinfo_proc *result;
int name[6];
name[0] = CTL_KERN;
- name[1] = KERN_PROC2;
+ name[1] = KERN_PROC;
name[2] = KERN_PROC_ALL;
name[3] = 0;
- name[4] = sizeof(struct kinfo_proc2);
+ name[4] = sizeof(struct kinfo_proc);
name[5] = 0;
#else
struct kinfo_proc *result;
return FALSE;
#if defined(__OpenBSD__)
- name[5] = (int)(proclength / sizeof(struct kinfo_proc2));
+ name[5] = (int)(proclength / sizeof(struct kinfo_proc));
#endif
err = sysctl ((int *) name, size, result, &proclength, NULL, 0);
return(FALSE);
}
-#if defined(__OpenBSD__)
- count = proclength / sizeof(struct kinfo_proc2);
-#else
count = proclength / sizeof(struct kinfo_proc);
-#endif
+
fit = len / sizeof(guint32);
for (i = 0, j = 0; j< fit && i < count; i++) {
#if defined(__OpenBSD__)
if (process_handle->id == getpid ()) {
struct rusage time_data;
if (getrusage (RUSAGE_SELF, &time_data) == 0) {
- gint64 tick_val;
- gint64 *tick_val_ptr;
+ guint64 tick_val;
ku_times_set = TRUE;
- tick_val = time_data.ru_utime.tv_sec * 10000000 + time_data.ru_utime.tv_usec * 10;
- tick_val_ptr = (gint64*)user_time;
- *tick_val_ptr = tick_val;
- tick_val = time_data.ru_stime.tv_sec * 10000000 + time_data.ru_stime.tv_usec * 10;
- tick_val_ptr = (gint64*)kernel_time;
- *tick_val_ptr = tick_val;
+ tick_val = (guint64)time_data.ru_utime.tv_sec * 10000000 + (guint64)time_data.ru_utime.tv_usec * 10;
+ _wapi_guint64_to_filetime (tick_val, user_time);
+ tick_val = (guint64)time_data.ru_stime.tv_sec * 10000000 + (guint64)time_data.ru_stime.tv_usec * 10;
+ _wapi_guint64_to_filetime (tick_val, kernel_time);
}
}
#endif
#if defined(__OpenBSD__)
int mib [6];
size_t size;
- struct kinfo_proc2 *pi;
+ struct kinfo_proc *pi;
#elif defined(PLATFORM_MACOSX)
#if !(!defined (__mono_ppc__) && defined (TARGET_OSX))
size_t size;
#endif
#elif defined(__OpenBSD__)
mib [0] = CTL_KERN;
- mib [1] = KERN_PROC2;
+ mib [1] = KERN_PROC;
mib [2] = KERN_PROC_PID;
mib [3] = pid;
- mib [4] = sizeof(struct kinfo_proc2);
+ mib [4] = sizeof(struct kinfo_proc);
mib [5] = 0;
retry:
if ((pi = malloc(size)) == NULL)
return(ret);
- mib[5] = (int)(size / sizeof(struct kinfo_proc2));
+ mib[5] = (int)(size / sizeof(struct kinfo_proc));
if ((sysctl (mib, 6, pi, &size, NULL, 0) < 0) ||
- (size != sizeof (struct kinfo_proc2))) {
+ (size != sizeof (struct kinfo_proc))) {
if (errno == ENOMEM) {
free(pi);
goto retry;
return ret;
}
+/*
+ * wapi_process_get_path:
+ *
+ * Return the full path of the executable of the process PID, or NULL if it cannot be determined.
+ * Returns malloc-ed memory.
+ */
+gchar*
+wapi_process_get_path (pid_t pid)
+{
+#if defined(PLATFORM_MACOSX) && !defined(__mono_ppc__) && defined(TARGET_OSX)
+ gchar buf [PROC_PIDPATHINFO_MAXSIZE];
+ int res;
+
+ res = proc_pidpath (pid, buf, sizeof (buf));
+ if (res <= 0)
+ return NULL;
+ if (buf [0] == '\0')
+ return NULL;
+ return g_strdup (buf);
+#else
+ return get_process_name_from_proc (pid);
+#endif
+}
+
+/*
+ * wapi_process_set_cli_launcher:
+ *
+ * Set the full path of the runtime executable used to launch managed exe's.
+ */
+void
+wapi_process_set_cli_launcher (char *path)
+{
+ g_free (cli_launcher);
+ cli_launcher = path ? g_strdup (path) : NULL;
+}
+
static guint32 get_module_name (gpointer process, gpointer module,
gunichar2 *basename, guint32 size,
gboolean base)
return WAIT_OBJECT_0;
}
+void
+wapi_processes_cleanup (void)
+{
+ g_free (cli_launcher);
+}