Portable keyboard signal handling

Robert Dockins robdockins at fastmail.fm
Fri Sep 1 11:05:03 EDT 2006

On Friday 01 September 2006 03:55, Simon Peyton-Jones wrote:
> | Indeed.  I had to browse the source after finding that the Haddock
> docs are
> | essentially useless.  I do have to say, one nice side effect of using
> darcs
> | is that one can simply point one's browser at the source repository to
> peruse
> | the code.  I've bookmarked http://cvs.haskell.org/darcs   :-)
> Good idea.  Could you help us improve the documentation by sending darcs
> patches with Haddock docs in them?  Not necessarily comprehensive: at
> least recording the bits you discovered, and wished had been in the docs
> in the first place.

Well, here's the odd thing; there ought to be meaningful haddock docs already.  
By that, I mean that there are data declarations and type signatures and such 
already in the file that haddock should be picking up on.  However, the whole 
file is protected by a big ifdef:

module GHC.ConsoleHandler
#if !defined(mingw32_HOST_OS) && !defined(__HADDOCK__)
import Prelude -- necessary to get dependencies right
#else /* whole file */
	( Handler(..)
	, installHandler
	, ConsoleEvent(..)
	, flushConsole
	) where

..... rest of file ....

It looks like the definitions in the file _should_ be visible to haddock, but 
for some reason they aren't.  So, this looks like a build system problem of 
some sort to me.  I don't know how the docs are built, so I'm not sure how 
one would go about fixing this.

> Thanks!
> Simon

Do you have any ideas about the original question?  It looks like RTS trickery 
is necessary to get this right in general.  Looking at this file in a little 
more detail, I see calls to 'rts_installHandler', which is surely why this 
file is in the GHC.* namespace.

Perhaps 'withControlCHandler' or something like it should go into the 
libraries somewhere?  I'm not sure this is a function that can be provided 
without RTS assistance.  It also seems to be about the maximum intersection 
of the capabilities of Posix signals and of the Win32 console events system.

Rob Dockins

Talk softly and drive a Sherman tank.
Laugh hard, it's a long way to the bank.
       -- TMBG

More information about the Libraries mailing list