Skip to content
Snippets Groups Projects
Commit 1862438e authored by sof's avatar sof
Browse files

[project @ 1999-09-22 11:53:33 by sof]

At startup time, install a SIGINT termination handler which calls
shutdownHaskellAndExit(), if invoked.
parent 1b5434e0
No related merge requests found
/* -----------------------------------------------------------------------------
* $Id: RtsStartup.c,v 1.20 1999/09/15 13:45:20 simonmar Exp $
* $Id: RtsStartup.c,v 1.21 1999/09/22 11:53:33 sof Exp $
*
* (c) The GHC Team, 1998-1999
*
......@@ -121,9 +121,11 @@ startupHaskell(int argc, char *argv[])
/* Initialise the stats department */
initStats();
/* Initialise the user signal handler set */
#if !defined(mingw32_TARGET_OS) && !defined(PAR)
/* Initialise the user signal handler set */
initUserSignals();
/* Set up handler to run on SIGINT */
init_shutdown_handler();
#endif
/* When the RTS and Prelude live in separate DLLs,
......@@ -179,7 +181,7 @@ shutdownHaskell(void)
/* stop the ticker */
initialize_virtual_timer(0);
#if defined(PROFILING) || defined(DEBUG)
endProfiling();
#endif
......
/* -----------------------------------------------------------------------------
* $Id: Signals.c,v 1.7 1999/07/14 13:39:46 simonmar Exp $
* $Id: Signals.c,v 1.8 1999/09/22 11:53:33 sof Exp $
*
* (c) The GHC Team, 1998-1999
*
......@@ -245,4 +245,38 @@ start_signal_handlers(void)
}
#endif
static void
shutdown_handler(int sig)
{
shutdownHaskellAndExit(EXIT_FAILURE);
}
/*
* The RTS installs a default signal handler for catching
* SIGINT, so that we can perform an orderly shutdown (finalising
* objects and flushing buffers etc.)
*
* 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.
*/
void
init_shutdown_handler()
{
struct sigaction action,oact;
action.sa_handler = shutdown_handler;
sigemptyset(&action.sa_mask);
action.sa_flags = 0;
if (sigaction(SIGINT, &action, &oact) != 0) {
/* Oh well, at least we tried. */
#ifdef DEBUG
fprintf(stderr, "init_shutdown_handler: failed to reg SIGINT handler");
#endif
}
}
#endif /*! mingw32_TARGET_OS */
/* -----------------------------------------------------------------------------
* $Id: Signals.h,v 1.3 1999/02/05 16:02:55 simonm Exp $
* $Id: Signals.h,v 1.4 1999/09/22 11:53:33 sof Exp $
*
* (c) The GHC Team, 1998-1999
*
......@@ -22,6 +22,8 @@ extern void unblockUserSignals(void);
extern void start_signal_handlers(void);
extern void init_shutdown_handler(void);
#else
#define signals_pending() (rtsFalse)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment