[runtime] Fix the leaking of mach ports introduced by 98bbf8512aec0fa01b4426583280f6d...
authorZoltan Varga <vargaz@gmail.com>
Fri, 15 Aug 2014 13:56:47 +0000 (09:56 -0400)
committerZoltan Varga <vargaz@gmail.com>
Fri, 15 Aug 2014 13:56:47 +0000 (09:56 -0400)
mono/utils/mono-proclib.c

index 279db86d96da59151341601fa355434a40b51815..3f032f9d22c321ff8bd4627d2459557c54c5756b 100644 (file)
@@ -417,7 +417,8 @@ get_pid_status_item (int pid, const char *item, MonoProcessError *error, int mul
        }
        
        if (task_info (task, TASK_BASIC_INFO, (task_info_t)&t_info, &th_count) != KERN_SUCCESS) {
-               mach_port_deallocate (mach_task_self (), task);
+               if (pid != getpid ())
+                       mach_port_deallocate (mach_task_self (), task);
                RET_ERROR (MONO_PROCESS_ERROR_OTHER);
        }
 
@@ -430,7 +431,8 @@ get_pid_status_item (int pid, const char *item, MonoProcessError *error, int mul
        else
                ret = 0;
 
-       mach_port_deallocate (mach_task_self (), task);
+       if (pid != getpid ())
+               mach_port_deallocate (mach_task_self (), task);
        
        return ret;
 #else