From c1b0a3f0d3a89b9e9d1af0648c4e8c75cde7f90f Mon Sep 17 00:00:00 2001 From: oliverschmidt Date: Sat, 14 Apr 2007 14:28:19 +0000 Subject: [PATCH] Cygin (in opposite to VC++) doesn't call exit() - and thus our atexit function - on Ctrl-C. Therefore we install an explict ConsoleCtrlHandler which calls exit(). For the sake of simplicity it's not #ifdef'ed _CYGWIN_. --- platform/win32/ctk/ctk-console.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/platform/win32/ctk/ctk-console.c b/platform/win32/ctk/ctk-console.c index 165ac4198..18246a133 100644 --- a/platform/win32/ctk/ctk-console.c +++ b/platform/win32/ctk/ctk-console.c @@ -30,7 +30,7 @@ * * Author: Oliver Schmidt * - * $Id: ctk-console.c,v 1.6 2007/04/06 23:09:33 oliverschmidt Exp $ + * $Id: ctk-console.c,v 1.7 2007/04/14 14:28:19 oliverschmidt Exp $ */ #define WIN32_LEAN_AND_MEAN @@ -67,6 +67,16 @@ static unsigned short xpos; static unsigned short ypos; static unsigned char button; +/*-----------------------------------------------------------------------------------*/ +static BOOL WINAPI +ctrlhandler(DWORD ctrltype) +{ + if(ctrltype == CTRL_C_EVENT) { + exit(EXIT_SUCCESS); + return TRUE; + } + return FALSE; +} /*-----------------------------------------------------------------------------------*/ void console_init(void) @@ -94,6 +104,7 @@ console_init(void) GetConsoleCursorInfo(stdouthandle, &saved_cursorinfo); SetConsoleCursorInfo(stdouthandle, &cursorinfo); + SetConsoleCtrlHandler(ctrlhandler, TRUE); atexit(console_exit); memset(blank, ' ', sizeof(blank));