- if (kill (process_handle->id, 0) == -1 &&
- (errno == ESRCH ||
- errno == EPERM)) {
- /* The process is dead, (EPERM tells us a new process
- * has that ID, but as it's owned by someone else it
- * can't be the one listed in our shared memory file)
- */
- _wapi_shared_handle_set_signal_state (handle, TRUE);
- }
-
- return (process_handle->id);
-}
-
-#ifdef UNUSED_CODE
-static gboolean process_enum (gpointer handle, gpointer user_data)
-{
- GArray *processes=user_data;
- pid_t pid = signal_process_if_gone (handle);
- int i;
-
- if (pid == 0) {
- return (FALSE);
- }
-
- /* Ignore processes that have already exited (ie they are signalled) */
- if (_wapi_handle_issignalled (handle) == FALSE) {
- DEBUG ("%s: process %d added to array", __func__, pid);
-
- /* This ensures that duplicates aren't returned (see
- * the comment above _wapi_search_handle () for why
- * it's needed
- */
- for (i = 0; i < processes->len; i++) {
- if (g_array_index (processes, pid_t, i) == pid) {
- /* We've already got this one, return
- * FALSE to keep searching
- */
- return (FALSE);
- }
- }
-
- g_array_append_val (processes, pid);
- }
-
- /* Return false to keep searching */
- return(FALSE);
-}
-#endif /* UNUSED_CODE */
-
-#if defined(PLATFORM_MACOSX) || defined(__OpenBSD__)
-
-gboolean EnumProcesses (guint32 *pids, guint32 len, guint32 *needed)
-{
- guint32 count, fit, i, j;
- gint32 err;
- gboolean done;
- size_t proclength, size;
-#if defined(__OpenBSD__)
- struct kinfo_proc *result;
- int name[6];
- name[0] = CTL_KERN;
- name[1] = KERN_PROC;
- name[2] = KERN_PROC_ALL;
- name[3] = 0;
- name[4] = sizeof(struct kinfo_proc);
- name[5] = 0;
-#else
- struct kinfo_proc *result;
- static const int name[] = { CTL_KERN, KERN_PROC, KERN_PROC_ALL, 0 };
-#endif
-
- mono_once (&process_current_once, process_set_current);
-
- result = NULL;
- done = FALSE;
-
- do {
- proclength = 0;
-#if defined(__OpenBSD__)
- size = (sizeof(name) / sizeof(*name));
-#else
- size = (sizeof(name) / sizeof(*name)) - 1;
-#endif
- err = sysctl ((int *)name, size, NULL, &proclength, NULL, 0);
-
- if (err == 0) {
- result = malloc (proclength);
-
- if (result == NULL)
- return FALSE;