* Windows console control handler. * Called when Ctrl+C, Ctrl+Break, or window close events occur. */
| 35 | * Called when Ctrl+C, Ctrl+Break, or window close events occur. |
| 36 | */ |
| 37 | static 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 | |
| 68 | void installSignalHandlers() |
| 69 | { |
nothing calls this directly
no outgoing calls
no test coverage detected