Commit e4efc1a2 authored by simonmar's avatar simonmar
Browse files

[project @ 2004-12-17 15:14:47 by simonmar]

Support for Ctrl-C on Windows.

This works fine in a cmd.exe shell, but in a Cygwin bash shell you
have to press Ctrl-Break to get an interrupt.  There appears to be a
long thread on the cygwin mailing list back in 2002 about this, but
life is probably too short to investigate further.

  http://www.cygwin.com/ml/cygwin/2002-01/msg00163.html
parent c69886a1
......@@ -32,10 +32,12 @@ import System.Posix.Signals
# else
import Posix ( Handler(Catch), installHandler, sigINT, sigQUIT )
# endif /* GHC > 504 */
import CONCURRENT ( myThreadId )
#endif /* mingw32_HOST_OS */
#if defined(mingw32_HOST_OS) && __GLASGOW_HASKELL__ >= 603
import GHC.ConsoleHandler
#endif
# if __GLASGOW_HASKELL__ < 500
import EXCEPTION ( raiseInThread )
# else
......@@ -46,6 +48,7 @@ import EXCEPTION ( throwTo )
import EXCEPTION ( catchJust, tryJust, ioErrors )
#endif
import CONCURRENT ( myThreadId )
import DYNAMIC
import qualified EXCEPTION as Exception
import TRACE ( trace )
......@@ -196,12 +199,24 @@ thread.
\begin{code}
installSignalHandlers :: IO ()
installSignalHandlers = do
#ifndef mingw32_HOST_OS
main_thread <- myThreadId
let sig_handler = Catch (throwTo main_thread
(Exception.DynException (toDyn Interrupted)))
installHandler sigQUIT sig_handler Nothing
installHandler sigINT sig_handler Nothing
#endif
let
interrupt_exn = Exception.DynException (toDyn Interrupted)
interrupt = throwTo main_thread interrupt_exn
--
#if !defined(mingw32_HOST_OS)
installHandler sigQUIT interrupt Nothing
installHandler sigINT interrupt Nothing
return ()
#elif __GLASGOW_HASKELL__ >= 603
-- GHC 6.3+ has support for console events on Windows
let sig_handler ControlC = interrupt
sig_handler Break = interrupt
sig_handler _ = return ()
installHandler (Catch sig_handler)
return ()
#else
-- nothing
#endif
\end{code}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment