SIGALRM, SIGVTALRM, and third party libraries

Bryan O'Sullivan bos at serpentine.com
Fri Sep 3 17:00:03 EDT 2010


I spent some time this morning trying to use HDBC-mysql to talk to a
database. It uses the C mysql bindings, which talks over a blocking socket
to the database server. Not surprisingly, it fails reliably when the thread
it's running in is hit by an RTS-initiated alarm signal.

I've managed to make the code *appear* to work successfully with some
hacking:

   - Run in a bound thread
   - Use pthread_sigmask to temporarily block SIGALRM and SIGVTALRM to
   *only* this thread while issuing the sensitive native calls
   - Profit?

What I am wondering is if there's a practical downside to doing this. Am I
going to accidentally kill something? This is a very important gap in the
usability of GHC with native libraries, and if this approach actually turns
out to be safe in practice, that would be wonderful.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/glasgow-haskell-users/attachments/20100903/bf545b7c/attachment.html


More information about the Glasgow-haskell-users mailing list