[Mono-dev] Control-C handler

Paolo Molaro lupus at ximian.com
Mon Jan 28 15:10:43 EST 2008


On 01/28/08 Jonathan Pryor wrote:
> > It is important (as in my initialy API sketch) that this function take
> > the signal_info and not the dignal number, as this implementation allows
> > only just an handler per signal in the API.
> 
> This has been corrected.  We now support up to 64 signal handlers within
> a process, and the same signal can be registered multiple times; each
> such registration gets a different index, and is thus independent.

Deregistration is handled incorrectly: if there are two handlers for the
same signal it gets disabled at the first uninstall.

> The only other major change is the addition of a
> UnixSignal.WaitAny(UnixSignal[]) method, which allows waiting on more
> than one handle (since WaitHandle.WaitAny() can't currently be used with
> WaitHandle subclasses like UnixSignal).

I suggest using params in the array argument.

> +int
> +Mono_Unix_UnixSignal_WaitAny (void** _signals, int count, int timeout /* milliseconds */)
> +{
> +	fd_set read_fds;
> +	int mr, r;
> +	int max_fd = 0;
> +
> +	signal_info** signals = (signal_info**) _signals;
> +
> +	mr = pthread_mutex_lock (&signals_mutex);
> +	if (mr != 0) {
> +		errno = mr;
> +		return -1;

You don't unlock in the return path.
An extensive test program that shows this stuff works before being
committed would also help.
Thanks.

lupus

-- 
-----------------------------------------------------------------
lupus at debian.org                                     debian/rules
lupus at ximian.com                             Monkeys do it better



More information about the Mono-devel-list mailing list