stg_InstallConsoleEvent(): registering generic_handler() once will do
if ( !SetConsoleCtrlHandler(shutdown_handler, TRUE) ) {
prog_belch("warning: failed to install default console handler");
}
-
}
break;
case STG_SIG_HAN:
console_handler = (StgInt)*handler;
- if ( !SetConsoleCtrlHandler(generic_handler, TRUE) ) {
+ if ( previous_hdlr < 0 ) {
+ /* Only install generic_handler() once */
+ if ( !SetConsoleCtrlHandler(generic_handler, TRUE) ) {
prog_belch("warning: unable to install console event handler");
+ }
}
break;
}