From a71f85236ef3a4caaa58a0dc364238144b135e62 Mon Sep 17 00:00:00 2001 From: sewardj Date: Wed, 28 Jun 2000 10:42:17 +0000 Subject: [PATCH] [project @ 2000-06-28 10:42:17 by sewardj] Partially fix signal (control-C) handling under mingw32. The interpreter can now be interrupted and successfully returns to the Hugs prompt, but only if Hugs was started from cmd.exe and not by bash (!). This is a known bogon with Cygwin, according to Sigbjorn. I still can't get Hugs to ignore other control-C's; instead it acts as if it was asked to exit. Bizarre. --- ghc/interpreter/connect.h | 8 +++++--- ghc/interpreter/hugs.c | 18 ++++++++++++++++-- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/ghc/interpreter/connect.h b/ghc/interpreter/connect.h index 0aae63b..a93a265 100644 --- a/ghc/interpreter/connect.h +++ b/ghc/interpreter/connect.h @@ -9,8 +9,8 @@ * included in the distribution. * * $RCSfile: connect.h,v $ - * $Revision: 1.43 $ - * $Date: 2000/05/26 10:14:33 $ + * $Revision: 1.44 $ + * $Date: 2000/06/28 10:42:17 $ * ------------------------------------------------------------------------*/ /* -------------------------------------------------------------------------- @@ -578,7 +578,9 @@ extern HugsBreakAction setBreakAction ( HugsBreakAction ); #else -#define setHandler(bh) do { } while(0) +#define setHandler(bh) { void* old_hdlr = signal(SIGINT,bh);\ + if (old_hdlr == SIG_ERR) internal("setHandler"); \ + } #endif /* !defined(mingw32_TARGET_OS) */ diff --git a/ghc/interpreter/hugs.c b/ghc/interpreter/hugs.c index 67c637b..bdb4bf6 100644 --- a/ghc/interpreter/hugs.c +++ b/ghc/interpreter/hugs.c @@ -9,8 +9,8 @@ * included in the distribution. * * $RCSfile: hugs.c,v $ - * $Revision: 1.77 $ - * $Date: 2000/06/23 12:09:01 $ + * $Revision: 1.78 $ + * $Date: 2000/06/28 10:42:17 $ * ------------------------------------------------------------------------*/ #include @@ -873,6 +873,18 @@ HugsBreakAction setBreakAction ( HugsBreakAction newAction ) { HugsBreakAction tmp = currentBreakAction; currentBreakAction = newAction; + +# if defined(mingw32_TARGET_OS) + /* Be wierd. You can't longjmp in a signal handler, + and posix signals are not supported. + */ + if (newAction == HugsRtsInterrupt) { + setHandler ( handler_RtsInterrupt ); + } else { + signal(SIGINT,SIG_IGN); + } +# else + /* do it Right */ switch (newAction) { case HugsIgnoreBreak: setHandler ( handler_IgnoreBreak ); break; @@ -883,6 +895,8 @@ HugsBreakAction setBreakAction ( HugsBreakAction newAction ) default: internal("setBreakAction"); } +# endif + return tmp; } -- 1.7.10.4