(not) catching ^C in ghc-built application

Malcolm Wallace Malcolm.Wallace@cs.york.ac.uk
Mon, 12 Aug 2002 15:05:58 +0100

Hi ghc users,

I have a program, written in a mixture of Haskell and C, in which the
C part is supposed to handle a ^C interrupt, accomplished through the
usual signal() call.  It works as expected when the Haskell part is
compiled by nhc98.  But when it is compiled by ghc, for some reason
the ghc RTS appears to trap the interrupt itself, and halts the
program with the message
    prog: interrupted
instead of allowing the newly installed C signal handler to run.

I have looked through the ghc user manual for some means to turn off or
divert the RTS signal-handling, but I couldn't find anything relevant.
The nearest thing is Exception.block, which excludes an asynchronous
exception from happening whilst the `block' is in operation, but that
doesn't seem to stop a ^C from interrupting the program, so I guess
that isn't its real purpose.

So, what should I use instead?