From a119b491c06bb2d89d4c04f9fc7556ab39bc121c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Kochma=C5=84ski?= Date: Tue, 2 Feb 2016 13:14:36 +0100 Subject: [PATCH] windows: handle events --- src/c/unixint.d | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/c/unixint.d b/src/c/unixint.d index 861c6dc12..a0d0d95ee 100644 --- a/src/c/unixint.d +++ b/src/c/unixint.d @@ -1119,10 +1119,32 @@ _ecl_w32_exception_filter(struct _EXCEPTION_POINTERS* ep) return excpt_result; } +static cl_object +W32_handle_in_new_thread(cl_object signal_code) +{ + int outside_ecl = ecl_import_current_thread(@'si::handle-signal', ECL_NIL); + mp_process_run_function(4, @'si::handle-signal', + @'si::handle-signal', + signal_code, ECL_NIL); + if (outside_ecl) ecl_release_current_thread(); +} + BOOL WINAPI W32_console_ctrl_handler(DWORD type) { switch (type) { - case CTRL_C_EVENT: /* Catch CTRL-C (ignore interrupt) */ + case CTRL_C_EVENT: + case CTRL_BREAK_EVENT: { + cl_object function = ECL_SYM_FUN(@'si::terminal-interrupt'); + if (function) + W32_handle_in_new_thread(function); + return TRUE; + } + case CTRL_CLOSE_EVENT: + case CTRL_LOGOFF_EVENT: + case CTRL_SHUTDOWN_EVENT: + cl_object function = ECL_SYM_FUN(@'si::quit'); + if (function) + W32_handle_in_new_thread(function); return TRUE; default: return FALSE;