Proposal: new signal-handling API

Simon Marlow marlowsd at gmail.com
Mon Jul 21 05:43:04 EDT 2008


I wrote:

> Synchronising with signal handlers should be done using ordinary thread 
> synchronisation.  Have one big signal lock if you like, or one per 
> signal, or one per handler - it's up to you.
> 
> It's true that you can't synchronise with other people's signal handlers 
> this way.  But I think that's a feature, or at least not a bug.  Even 
> using SIG_IGN or sigprocmask() you couldn't stop a handler that had 
> already been started anyway.

It just occurred to me that it would be relatively easy to add back support 
for blocking signals in a way that makes sense.  We could add one MVar per 
signal, and have every signal handler do something like

    withMVar sigINT_lock $ \_ -> do ...

(implemented under the hood in the API).  That would let us provide a way 
to temporarily disable handlers for particular signals.

It would have the effect of serialising the handlers for each signal too, 
I'm not sure if that's a good thing.  We could provide a back door too, 
perhaps.

Cheers,
	Simon


More information about the Libraries mailing list