Handle CTRL+C on Win32
问题 I have some problems with the handling of CTRL + C events, in a Win32 C++ console program. Basically my program looks like this: (based on this other question: Windows Ctrl-C - Cleaning up local stack objects in command line app) bool running; int main() { running = true; SetConsoleCtrlHandler((PHANDLER_ROUTINE) consoleHandler, TRUE); while (running) { // do work ... } // do cleanup ... return 0; } bool consoleHandler(int signal) { if (signal == CTRL_C_EVENT) { running = false; } return true;