[runtime] Use mono_set_pending_exception () in some places in icalls.
[mono.git] / mono / metadata / process.c
index bbeaf97dc0d74f8440955d0b2f73eefc5fdca5f2..f4d4e3044d3cb534194740d93bf2da54933b5bc4 100644 (file)
@@ -789,7 +789,8 @@ MonoString *ves_icall_System_Diagnostics_Process_ProcessName_internal (HANDLE pr
 }
 
 /* Returns an array of pids */
-MonoArray *ves_icall_System_Diagnostics_Process_GetProcesses_internal (void)
+MonoArray *
+ves_icall_System_Diagnostics_Process_GetProcesses_internal (void)
 {
 #if !defined(HOST_WIN32)
        MonoArray *procs;
@@ -797,8 +798,10 @@ MonoArray *ves_icall_System_Diagnostics_Process_GetProcesses_internal (void)
        int i, count;
 
        pidarray = mono_process_list (&count);
-       if (!pidarray)
-               mono_raise_exception (mono_get_exception_not_supported ("This system does not support EnumProcesses"));
+       if (!pidarray) {
+               mono_set_pending_exception (mono_get_exception_not_supported ("This system does not support EnumProcesses"));
+               return NULL;
+       }
        procs = mono_array_new (mono_domain_get (), mono_get_int32_class (), count);
        if (sizeof (guint32) == sizeof (gpointer)) {
                memcpy (mono_array_addr (procs, guint32, 0), pidarray, count);
@@ -826,8 +829,8 @@ MonoArray *ves_icall_System_Diagnostics_Process_GetProcesses_internal (void)
                        g_free (pids);
                        pids = NULL;
                        exc = mono_get_exception_not_supported ("This system does not support EnumProcesses");
-                       mono_raise_exception (exc);
-                       g_assert_not_reached ();
+                       mono_set_pending_exception (exc);
+                       return NULL;
                }
                if (needed < (count * sizeof (guint32)))
                        break;