// 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) {
+ if (sched_state >= SCHED_INTERRUPTING) {
stg_exit(EXIT_INTERRUPTED);
} else {
interruptStgRts();
* Run the handlers associated with the stacked up console events. Console
* event delivery is blocked for the duration of this call.
*/
-void startSignalHandlers(void)
+void startSignalHandlers(Capability *cap)
{
StgStablePtr handler;
if (console_handler < 0) {
return;
}
+
blockUserSignals();
+ ACQUIRE_LOCK(&sched_mutex);
handler = deRefStablePtr((StgStablePtr)console_handler);
while (stg_pending_events > 0) {
stg_pending_events--;
- scheduleThread(&MainCapability,
- createIOThread(&MainCapability,
+ scheduleThread(cap,
+ createIOThread(cap,
RtsFlags.GcFlags.initialStkSize,
- rts_apply(&MainCapability,
+ rts_apply(cap,
(StgClosure *)handler,
- rts_mkInt(&MainCapability,
+ rts_mkInt(cap,
stg_pending_buf[stg_pending_events]))));
}
+
+ RELEASE_LOCK(&sched_mutex);
unblockUserSignals();
}
-
/*
* Function: markSignalHandlers()
*
}
-/*
- * Function: handleSignalsInThisThread()
- *
- * Have current (OS) thread assume responsibility of handling console events/signals.
- * Currently not used (by the console event handling code.)
- */
-void handleSignalsInThisThread(void)
-{
- return;
-}
-
/*
* Function: generic_handler()
*
*/
static BOOL WINAPI generic_handler(DWORD dwCtrlType)
{
+ ACQUIRE_LOCK(&sched_mutex);
+
/* Ultra-simple -- up the counter + signal a switch. */
switch(dwCtrlType) {
case CTRL_CLOSE_EVENT:
resetAbandonRequestWait();
return TRUE;
}
+
+ RELEASE_LOCK(&sched_mutex);
}