MCPcopy Create free account
hub / github.com/alpha-liu-01/SpeedyNote / consoleCtrlHandler

Function consoleCtrlHandler

source/cli/CliSignal.cpp:37–66  ·  view source on GitHub ↗

* Windows console control handler. * Called when Ctrl+C, Ctrl+Break, or window close events occur. */

Source from the content-addressed store, hash-verified

35 * Called when Ctrl+C, Ctrl+Break, or window close events occur.
36 */
37static BOOL WINAPI consoleCtrlHandler(DWORD ctrlType)
38{
39 switch (ctrlType) {
40 case CTRL_C_EVENT:
41 case CTRL_BREAK_EVENT:
42 // Set cancellation flag
43 g_cancelled = true;
44
45 // Print message (only once)
46 if (!g_cancelMessagePrinted.exchange(true)) {
47 // Use stderr to avoid interfering with JSON output
48 QTextStream err(stderr);
49 err << "\nCancellation requested. Finishing current file...\n";
50 err.flush();
51 }
52
53 // Return TRUE to indicate we handled the signal
54 // This prevents the default handler from terminating the process
55 return TRUE;
56
57 case CTRL_CLOSE_EVENT:
58 case CTRL_LOGOFF_EVENT:
59 case CTRL_SHUTDOWN_EVENT:
60 // For these events, allow default handling (process termination)
61 return FALSE;
62
63 default:
64 return FALSE;
65 }
66}
67
68void installSignalHandlers()
69{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected