janneke pushed a commit to branch wip-mingw in repository guile. commit 11b25e2f520ce3fe52b67f6a5683b40dcb3d8d7a Author: Jan (janneke) Nieuwenhuizen <jann...@gnu.org> AuthorDate: Fri Oct 30 13:32:00 2020 +0100
Install 'mingw_take_signal' on MinGW. After installing a signal handler, these are handled * C-c * kill -SIGINT <guile.exe-pid> (the wine process) works these result in a direct terminate (or kill even?) - kill <guile.exe-pid> - wine cmd /c guile -c '(kill <guile-exe.pid> SIGINT)' - wine cmd /c guile -c '(kill <guile-exe.pid> SIGTERM)' * libguile/scmsigs.c (mingw_take_signal)[__MINGW32__]: New function. install_mingw_take_signal)[__MINGW32__]: New function. (scm_init_scmsigs)[__MINGW32__]: Use it. --- libguile/scmsigs.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/libguile/scmsigs.c b/libguile/scmsigs.c index d1daf04..6359d2c 100644 --- a/libguile/scmsigs.c +++ b/libguile/scmsigs.c @@ -41,6 +41,11 @@ #include <full-write.h> +#ifdef __MINGW32__ +# define WIN32_LEAN_AND_MEAN +# include <windows.h> +#endif + #include "async.h" #include "boolean.h" #include "dynwind.h" @@ -264,6 +269,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) { @@ -740,6 +769,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_long ((long) SIG_IGN)); scm_c_define ("SIG_DFL", scm_from_long ((long) SIG_DFL));