X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Frts%2Fwin32%2FConsoleHandler.c;h=4220f29145e0c7b3a3acef2e2cfe900f25b6e880;hb=3bb535af4751025d75afa89d3f410554f4071a9f;hp=c8ef67d3b4202834d2cfbc2e55fd199cb32f3b3a;hpb=d0c6e4ecff3276cdd91b4d66dbb85084aaf8d5c8;p=ghc-hetmet.git diff --git a/ghc/rts/win32/ConsoleHandler.c b/ghc/rts/win32/ConsoleHandler.c index c8ef67d..4220f29 100644 --- a/ghc/rts/win32/ConsoleHandler.c +++ b/ghc/rts/win32/ConsoleHandler.c @@ -9,7 +9,6 @@ #include "Schedule.h" #include "RtsUtils.h" #include "RtsFlags.h" -#include "StablePriv.h" extern int stg_InstallConsoleEvent(int action, StgStablePtr *handler); @@ -81,9 +80,8 @@ static BOOL WINAPI shutdown_handler(DWORD dwCtrlType) void initDefaultHandlers(void) { if ( !SetConsoleCtrlHandler(shutdown_handler, TRUE) ) { - prog_belch("warning: failed to install default console handler"); + errorBelch("warning: failed to install default console handler"); } - } @@ -210,19 +208,22 @@ stg_InstallConsoleEvent(int action, StgStablePtr *handler) case STG_SIG_IGN: console_handler = STG_SIG_IGN; if ( !SetConsoleCtrlHandler(NULL, TRUE) ) { - prog_belch("warning: unable to ignore console events"); + errorBelch("warning: unable to ignore console events"); } break; case STG_SIG_DFL: console_handler = STG_SIG_IGN; if ( !SetConsoleCtrlHandler(NULL, FALSE) ) { - prog_belch("warning: unable to restore default console event handling"); + errorBelch("warning: unable to restore default console event handling"); } break; case STG_SIG_HAN: console_handler = (StgInt)*handler; - if ( !SetConsoleCtrlHandler(generic_handler, TRUE) ) { - prog_belch("warning: unable to install console event handler"); + if ( previous_hdlr < 0 ) { + /* Only install generic_handler() once */ + if ( !SetConsoleCtrlHandler(generic_handler, TRUE) ) { + errorBelch("warning: unable to install console event handler"); + } } break; }