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_.

This commit is contained in:
oliverschmidt 2007-04-14 14:28:19 +00:00
parent df278abd09
commit c1b0a3f0d3

View file

@ -30,7 +30,7 @@
* *
* Author: Oliver Schmidt <ol.sc@web.de> * Author: Oliver Schmidt <ol.sc@web.de>
* *
* $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 #define WIN32_LEAN_AND_MEAN
@ -67,6 +67,16 @@ static unsigned short xpos;
static unsigned short ypos; static unsigned short ypos;
static unsigned char button; static unsigned char button;
/*-----------------------------------------------------------------------------------*/
static BOOL WINAPI
ctrlhandler(DWORD ctrltype)
{
if(ctrltype == CTRL_C_EVENT) {
exit(EXIT_SUCCESS);
return TRUE;
}
return FALSE;
}
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
void void
console_init(void) console_init(void)
@ -94,6 +104,7 @@ console_init(void)
GetConsoleCursorInfo(stdouthandle, &saved_cursorinfo); GetConsoleCursorInfo(stdouthandle, &saved_cursorinfo);
SetConsoleCursorInfo(stdouthandle, &cursorinfo); SetConsoleCursorInfo(stdouthandle, &cursorinfo);
SetConsoleCtrlHandler(ctrlhandler, TRUE);
atexit(console_exit); atexit(console_exit);
memset(blank, ' ', sizeof(blank)); memset(blank, ' ', sizeof(blank));