{
gboolean result = FALSE;
-#if defined(PLATFORM_MACOSX) || defined(__OpenBSD__) || defined(__FreeBSD__)
+#if defined(HOST_WATCHOS)
+ result = TRUE; // TODO: Rewrite using sysctl
+#elif defined(PLATFORM_MACOSX) || defined(__OpenBSD__) || defined(__FreeBSD__)
if (((kill(pid, 0) == 0) || (errno == EPERM)) && pid != 0)
result = TRUE;
#elif defined(__HAIKU__)
if (newapp != NULL) {
if (appname != NULL) {
- newcmd = utf16_concat (newapp, utf16_space,
+ newcmd = utf16_concat (utf16_quote, newapp, utf16_quote, utf16_space,
appname, utf16_space,
cmdline, NULL);
} else {
- newcmd = utf16_concat (newapp, utf16_space,
+ newcmd = utf16_concat (utf16_quote, newapp, utf16_quote, utf16_space,
cmdline, NULL);
}
if (procname == NULL || modulename == NULL)
return (FALSE);
+ DEBUG ("%s: procname=\"%s\", modulename=\"%s\"", __func__, procname, modulename);
pname = mono_path_resolve_symlinks (procname);
mname = mono_path_resolve_symlinks (modulename);
g_free (pname);
g_free (mname);
+ DEBUG ("%s: result is %d", __func__, result);
return result;
}
}
#endif
+static char *get_process_name_from_proc (pid_t pid);
+
gboolean EnumProcessModules (gpointer process, gpointer *modules,
guint32 size, guint32 *needed)
{
if (WAPI_IS_PSEUDO_PROCESS_HANDLE (process)) {
pid = WAPI_HANDLE_TO_PID (process);
+ proc_name = get_process_name_from_proc (pid);
} else {
process_handle = lookup_process_handle (process);
if (!process_handle) {
free(pi);
#endif
-#elif defined(__OpenBSD__) || defined(__FreeBSD__)
+#elif defined(__FreeBSD__)
+ mib [0] = CTL_KERN;
+ mib [1] = KERN_PROC;
+ mib [2] = KERN_PROC_PID;
+ mib [3] = pid;
+ if (sysctl(mib, 4, NULL, &size, NULL, 0) < 0) {
+ DEBUG ("%s: sysctl() failed: %d", __func__, errno);
+ return(ret);
+ }
+
+ if ((pi = malloc(size)) == NULL)
+ return(ret);
+
+ if (sysctl (mib, 4, pi, &size, NULL, 0) < 0) {
+ if (errno == ENOMEM) {
+ free(pi);
+ DEBUG ("%s: Didn't allocate enough memory for kproc info", __func__);
+ }
+ return(ret);
+ }
+
+ if (strlen (pi->ki_comm) > 0)
+ ret = g_strdup (pi->ki_comm);
+ free(pi);
+#elif defined(__OpenBSD__)
mib [0] = CTL_KERN;
mib [1] = KERN_PROC;
mib [2] = KERN_PROC_PID;
mib [5] = 0;
retry:
- if (sysctl(mib, 6, NULL, &size, NULL, 0) < 0)
+ if (sysctl(mib, 6, NULL, &size, NULL, 0) < 0) {
+ DEBUG ("%s: sysctl() failed: %d", __func__, errno);
return(ret);
+ }
if ((pi = malloc(size)) == NULL)
return(ret);
gboolean
TerminateProcess (gpointer process, gint32 exitCode)
{
+#if defined(HAVE_KILL)
WapiHandle_process *process_handle;
int signo;
int ret;
}
return (ret == 0);
+#else
+ g_error ("kill() is not supported by this platform");
+ return FALSE;
+#endif
}
guint32