From dd3e3d70c0fe16cc5c6226cc91832dd545518f0b Mon Sep 17 00:00:00 2001
From: simonmar <unknown>
Date: Tue, 4 Apr 2000 10:04:47 +0000
Subject: [PATCH] [project @ 2000-04-04 10:04:47 by simonmar] - make the second
 ^C kill the program immediately (the first one tries   to interrupt it safely
 by killing all the threads, running   finalizers etc.).

- don't ignore SIGPIPE by default, the program can do this itself.
---
 ghc/rts/Signals.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/ghc/rts/Signals.c b/ghc/rts/Signals.c
index 0b9f3a99e85c..d5f0c756247f 100644
--- a/ghc/rts/Signals.c
+++ b/ghc/rts/Signals.c
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: Signals.c,v 1.15 2000/03/15 15:31:36 simonmar Exp $
+ * $Id: Signals.c,v 1.16 2000/04/04 10:04:47 simonmar Exp $
  *
  * (c) The GHC Team, 1998-1999
  *
@@ -264,7 +264,15 @@ shutdown_handler(int sig STG_UNUSED)
   } else
 #endif
 
-    interruptStgRts();
+  /* If we're already trying to interrupt the RTS, terminate with
+   * extreme prejudice.  So the first ^C tries to exit the program
+   * cleanly, and the second one just kills it.
+   */
+  if (interrupted) {
+      exit(EXIT_INTERRUPTED);
+  } else {
+      interruptStgRts();
+  }
 }
 
 /*
@@ -274,10 +282,6 @@ shutdown_handler(int sig STG_UNUSED)
  * Haskell code may install their own SIGINT handler, which is
  * fine, provided they're so kind as to put back the old one
  * when they de-install.
- *
- * We ignore SIGPIPE, because our I/O library handles EPIPE properly,
- * and a SIGPIPE tends to cause the program to exit silently and
- * mysteriously.
  */
 void
 init_default_handlers()
@@ -294,11 +298,6 @@ init_default_handlers()
       /* Oh well, at least we tried. */
       prog_belch("failed to install SIGINT handler");
     }
-
-    action.sa_handler = SIG_IGN;
-    if (sigaction(SIGPIPE, &action, &oact) != 0) {
-      prog_belch("failed to install SIGINT handler");
-    }
 }
 
 #endif /*! mingw32_TARGET_OS */
-- 
GitLab