[Mono-dev] [PATCHES] Improve process exit/wait handling

Rolf Bjarne Kvinge rolflists at ya.com
Fri Mar 18 10:33:52 EDT 2011


Hi,

>Awesome patches. Comments below.
>
>On Thu, 2011-03-17 at 00:26 +0100, Rolf Bjarne Kvinge wrote:
>>[...]
>> 4) Improve waiting on processes a lot
>>
>>    Here are all the juicy bits: I changed process waiting to use
>>    a SIGCHLD handler and automatically wait on all processes.
>>    This fixes #668867. I also added a semaphore, so waits are now
>>    properly handled by using that semaphore instead of polling
>>    every 100ms.
>
>In mono_sigchld_signal_handler(), there's this line:
>
>        while ((pid = waitpid (-1, &status, WNOHANG)) > 0) {
>
>You need to handle EINTR. Also info->si_pid has the PID of the process
>that triggered the signal so you could avoid doing a 'while' and call
>waitpid() like "waitpid (info->si_pid, ...".

According to the man page EINTR won't happen if WNOHANG is specified. I
modified it anyways.

There is a slight problem now which I just found out: SIGCHLD isn't 100%
reliable. If I start 100 threads, each of them spawning a process, I usually
get 98-99 signals (unless I run in gdb, in which case I get the same number
of signals, but info->si_pid is duplicated in many of them...). This means
that only waiting for the reported pid will quite often lead to a zombie
process in my (pathological) test case.

Attaching revised patch (which is identical to the one in my response to
Rodrigo).

Rolf

_______________________________________________
Mono-devel-list mailing list
Mono-devel-list at lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list 
________________________________________
No virus found in this message.
Checked by AVG - www.avg.com
Version: 10.0.1204 / Virus Database: 1498/3510 - Release Date: 03/16/11
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0004-io-layer-Improve-waiting-on-processes-a-lot.patch
Type: application/octet-stream
Size: 24195 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20110318/0d8a8c9f/attachment-0001.obj 


More information about the Mono-devel-list mailing list