/* -----------------------------------------------------------------------------
- * $Id: Signals.c,v 1.33 2003/01/25 15:54:50 wolfgang Exp $
+ * $Id: Signals.c,v 1.37 2003/04/01 15:05:22 sof Exp $
*
* (c) The GHC Team, 1998-1999
*
#include <stdlib.h>
-#ifndef mingw32_TARGET_OS
+/* This curious flag is provided for the benefit of the Haskell binding
+ * to POSIX.1 to control whether or not to include SA_NOCLDSTOP when
+ * installing a SIGCHLD handler.
+ *
+ */
+StgInt nocldstop = 0;
-#ifndef PAR
+#if defined(RTS_USER_SIGNALS)
/* SUP: The type of handlers is a little bit, well, doubtful... */
static StgInt *handlers = NULL; /* Dynamically grown array of signal handlers */
StgPtr pending_handler_buf[N_PENDING_HANDLERS];
StgPtr *next_pending_handler = pending_handler_buf;
-StgInt nocldstop = 0;
-
-
#ifdef RTS_SUPPORTS_THREADS
pthread_t signalHandlingThread;
#endif
return;
if (handlers == NULL)
- handlers = (StgInt *) malloc((sig + 1) * sizeof(StgInt));
+ handlers = (StgInt *)stgMallocBytes((sig + 1) * sizeof(StgInt), "more_handlers");
else
- handlers = (StgInt *) realloc(handlers, (sig + 1) * sizeof(StgInt));
+ handlers = (StgInt *)stgReallocBytes(handlers, (sig + 1) * sizeof(StgInt), "more_handlers");
- if (handlers == NULL) {
- // don't fflush(stdout); WORKAROUND bug in Linux glibc
- barf("VM exhausted (in more_handlers)");
- }
for(i = nHandlers; i <= sig; i++)
// Fill in the new slots with default actions
handlers[i] = STG_SIG_DFL;
}
}
-#else // PAR
+#else /* !RTS_USER_SIGNALS */
StgInt
-stg_sig_install(StgInt sig, StgInt spi, StgStablePtr handler, sigset_t *mask)
+stg_sig_install(StgInt sig STG_UNUSED,
+ StgInt spi STG_UNUSED,
+ StgStablePtr* handler STG_UNUSED,
+ void* mask STG_UNUSED)
{
- // don't fflush(stdout); WORKAROUND bug in Linux glibc
- barf("no signal handling support in a parallel implementation");
+ //barf("User signals not supported");
+ return STG_SIG_DFL;
}
-void
-startSignalHandlers(void)
-{
-}
#endif
+#if defined(RTS_USER_SIGNALS)
/* -----------------------------------------------------------------------------
* SIGINT handler.
*
// extreme prejudice. So the first ^C tries to exit the program
// cleanly, and the second one just kills it.
if (interrupted) {
- exit(EXIT_INTERRUPTED);
+ stg_exit(EXIT_INTERRUPTED);
} else {
interruptStgRts();
}
startup_guy = pthread_self();
#endif
#ifdef RTS_SUPPORTS_THREADS
- handleSignalsInThisThread();
+ handleSignalsInThisThread();
#endif
// install the SIGINT handler
#endif
}
-#endif /*! mingw32_TARGET_OS */
+#endif /* RTS_USER_SIGNALS */