projects
/
ghc-hetmet.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add stricter ghc-pkg checks on package file/dir/url fields
[ghc-hetmet.git]
/
rts
/
win32
/
ConsoleHandler.c
diff --git
a/rts/win32/ConsoleHandler.c
b/rts/win32/ConsoleHandler.c
index
a2de74b
..
19057a3
100644
(file)
--- a/
rts/win32/ConsoleHandler.c
+++ b/
rts/win32/ConsoleHandler.c
@@
-5,10
+5,8
@@
#include "Rts.h"
#include <windows.h>
#include "ConsoleHandler.h"
#include "Rts.h"
#include <windows.h>
#include "ConsoleHandler.h"
-#include "SchedAPI.h"
#include "Schedule.h"
#include "RtsUtils.h"
#include "Schedule.h"
#include "RtsUtils.h"
-#include "RtsFlags.h"
#include "AsyncIO.h"
#include "RtsSignals.h"
#include "AsyncIO.h"
#include "RtsSignals.h"
@@
-119,6
+117,12
@@
void initDefaultHandlers(void)
}
}
}
}
+void resetDefaultHandlers(void)
+{
+ if ( !SetConsoleCtrlHandler(shutdown_handler, FALSE) ) {
+ errorBelch("warning: failed to uninstall default console handler");
+ }
+}
/*
* Function: blockUserSignals()
/*
* Function: blockUserSignals()
@@
-199,7
+203,7
@@
void startSignalHandlers(Capability *cap)
* Evacuate the handler stack. _Assumes_ that console event delivery
* has already been blocked.
*/
* Evacuate the handler stack. _Assumes_ that console event delivery
* has already been blocked.
*/
-void markSignalHandlers (evac_fn evac STG_UNUSED)
+void markSignalHandlers (evac_fn evac STG_UNUSED, void *user STG_UNUSED)
{
// nothing to mark; the console handler is a StablePtr which is
// already treated as a root by the GC.
{
// nothing to mark; the console handler is a StablePtr which is
// already treated as a root by the GC.
@@
-234,6
+238,9
@@
static BOOL WINAPI generic_handler(DWORD dwCtrlType)
stg_pending_buf[stg_pending_events] = dwCtrlType;
stg_pending_events++;
}
stg_pending_buf[stg_pending_events] = dwCtrlType;
stg_pending_events++;
}
+
+ // we need to wake up awaitEvent()
+ abandonRequestWait();
#endif
return TRUE;
}
#endif
return TRUE;
}
@@
-264,8
+271,13
@@
rts_InstallConsoleEvent(int action, StgStablePtr *handler)
}
break;
case STG_SIG_HAN:
}
break;
case STG_SIG_HAN:
+#ifdef THREADED_RTS
+ // handler is stored in an MVar in the threaded RTS
+ console_handler = STG_SIG_HAN;
+#else
console_handler = (StgInt)*handler;
console_handler = (StgInt)*handler;
- if ( previous_hdlr < 0 ) {
+#endif
+ if (previous_hdlr < 0 || previous_hdlr == STG_SIG_HAN) {
/* Only install generic_handler() once */
if ( !SetConsoleCtrlHandler(generic_handler, TRUE) ) {
errorBelch("warning: unable to install console event handler");
/* Only install generic_handler() once */
if ( !SetConsoleCtrlHandler(generic_handler, TRUE) ) {
errorBelch("warning: unable to install console event handler");
@@
-275,10
+287,13
@@
rts_InstallConsoleEvent(int action, StgStablePtr *handler)
}
if (previous_hdlr == STG_SIG_DFL ||
}
if (previous_hdlr == STG_SIG_DFL ||
- previous_hdlr == STG_SIG_IGN) {
+ previous_hdlr == STG_SIG_IGN ||
+ previous_hdlr == STG_SIG_HAN) {
return previous_hdlr;
} else {
return previous_hdlr;
} else {
- *handler = (StgStablePtr)previous_hdlr;
+ if (handler != NULL) {
+ *handler = (StgStablePtr)previous_hdlr;
+ }
return STG_SIG_HAN;
}
}
return STG_SIG_HAN;
}
}