Author: dick
Date: 2006-08-11 08:11:44 -0400 (Fri, 11 Aug 2006)
New Revision: 63637

Modified:
   trunk/mono/mono/io-layer/ChangeLog
   trunk/mono/mono/io-layer/processes.c
Log:

2006-08-11  Dick Porter  <[EMAIL PROTECTED]>

        * processes.c (_wapi_process_reap): Avoid a deadlock by setting
        process termination details in an outer loop, not the
        _wapi_search_handle() one.




Modified: trunk/mono/mono/io-layer/ChangeLog
===================================================================
--- trunk/mono/mono/io-layer/ChangeLog  2006-08-11 11:48:52 UTC (rev 63636)
+++ trunk/mono/mono/io-layer/ChangeLog  2006-08-11 12:11:44 UTC (rev 63637)
@@ -1,3 +1,9 @@
+2006-08-11  Dick Porter  <[EMAIL PROTECTED]>
+
+       * processes.c (_wapi_process_reap): Avoid a deadlock by setting
+       process termination details in an outer loop, not the
+       _wapi_search_handle() one.
+
 2006-08-10  Dick Porter  <[EMAIL PROTECTED]>
 
        * threads.c (_wapi_thread_queue_apc)

Modified: trunk/mono/mono/io-layer/processes.c
===================================================================
--- trunk/mono/mono/io-layer/processes.c        2006-08-11 11:48:52 UTC (rev 
63636)
+++ trunk/mono/mono/io-layer/processes.c        2006-08-11 12:11:44 UTC (rev 
63637)
@@ -101,7 +101,7 @@
  * updating process handle info.  This function is called from the
  * collection thread every few seconds.
  */
-static gboolean waitfor_pid (gpointer test, gpointer user_data G_GNUC_UNUSED)
+static gboolean waitfor_pid (gpointer test, gpointer user_data)
 {
        struct _WapiHandle_process *process;
        gboolean ok;
@@ -138,20 +138,32 @@
        g_message ("%s: Process %d finished", __func__, ret);
 #endif
 
-       process_set_termination_details (test, status);
+       *(int *)user_data = status;
        
-       /* return FALSE to keep searching */
-       return (FALSE);
+       return (TRUE);
 }
 
 void _wapi_process_reap (void)
 {
+       gpointer proc;
+       int status;
+       
 #ifdef DEBUG
        g_message ("%s: Reaping child processes", __func__);
 #endif
 
-       _wapi_search_handle (WAPI_HANDLE_PROCESS, waitfor_pid, NULL, NULL,
-                            FALSE);
+       do {
+               proc = _wapi_search_handle (WAPI_HANDLE_PROCESS, waitfor_pid,
+                                           &status, NULL, FALSE);
+               if (proc != NULL) {
+#ifdef DEBUG
+                       g_message ("%s: process handle %p exit code %d",
+                                  __func__, proc, status);
+#endif
+                       
+                       process_set_termination_details (proc, status);
+               }
+       } while (proc != NULL);
 }
 
 /* Limitations: This can only wait for processes that are our own

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to