[Haskell-beginners] Signals and external bindings...

Brandon Allbery allbery.b at gmail.com
Wed May 2 19:46:39 CEST 2012


On Wed, May 2, 2012 at 1:00 PM, Mike Meyer <mwm at mired.org> wrote:

> One problem I ran into is that I use Unix signals to control the
> various processes. In CPython, this causes a problem with extension
> code because the python signal handler at the C level just note the
> signal, then wait to run the Python "signal handler" the next time the
> interpreter. Since my extensions are doing the heavy lifting, they
> often run for long periods (by which I mean 10s of minutes). Meaning
> the signal is ignored for long periods.
>
> Since I expect to such extensions (the wrappers are available) and
> want to leave the control mechanisms in place, I'd like to know if I'm
> going to have similar problems in Haskell.
>

Yes, and in pretty much any other language that requires its own runtime as
well.  Cross-runtime borders are *always* a problem for signals and various
resources that may need to be cleaned up.

You can use wrappers which save the old signal handlers and install new
ones which clean up after your plugins and return.  Doing so, and thereby
learning the hard way what "clean up after your plugins" entails (unless
you were very careful designing and writing them in the first place), will
teach you why nobody tries to automatically handle it for you.  (In the
general case, your plugin has to track *everything* so it can unwind (or
commit, as appropriate) memory and resource allocations on signal.)

-- 
brandon s allbery                                      allbery.b at gmail.com
wandering unix systems administrator (available)     (412) 475-9364 vm/sms
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20120502/ed398b48/attachment.htm>


More information about the Beginners mailing list