diff --git a/libguile/scmsigs.c b/libguile/scmsigs.c index c056a897b..17164f4cc 100644 --- a/libguile/scmsigs.c +++ b/libguile/scmsigs.c @@ -41,6 +41,11 @@ #include +#ifdef __MINGW32__ +# define WIN32_LEAN_AND_MEAN +# include +#endif + #include "async.h" #include "boolean.h" #include "dynwind.h" @@ -250,6 +255,30 @@ scm_i_ensure_signal_delivery_thread () #endif /* !SCM_USE_PTHREAD_THREADS */ +#ifdef __MINGW32__ + +static BOOL +mingw_take_signal (DWORD ctrl_signal) +{ + switch (ctrl_signal) + { + case CTRL_C_EVENT: + take_signal (SIGINT); + break; + case CTRL_BREAK_EVENT: + take_signal (SIGTERM); + break; + } + return TRUE; +} + +static void +install_mingw_take_signal () +{ + SetConsoleCtrlHandler ((PHANDLER_ROUTINE) mingw_take_signal, TRUE); +} +#endif /* __MINGW32__ */ + static void install_handler (int signum, SCM thread, SCM handler) { @@ -726,6 +755,10 @@ scm_init_scmsigs () #endif } +#ifdef __MINGW32__ + install_mingw_take_signal (); +#endif + scm_c_define ("NSIG", scm_from_long (NSIG)); scm_c_define ("SIG_IGN", scm_from_intptr_t ((intptr_t) SIG_IGN)); scm_c_define ("SIG_DFL", scm_from_intptr_t ((intptr_t) SIG_DFL));