| 1218 | } |
| 1219 | |
| 1220 | static void ctrl_c_handling() { |
| 1221 | #if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) |
| 1222 | struct sigaction sigint_action; |
| 1223 | sigint_action.sa_handler = sigint_handler; |
| 1224 | sigemptyset(&sigint_action.sa_mask); |
| 1225 | sigint_action.sa_flags = 0; |
| 1226 | sigaction(SIGINT, &sigint_action, NULL); |
| 1227 | #elif defined(_WIN32) |
| 1228 | auto console_ctrl_handler = +[](DWORD ctrl_type) -> BOOL { |
| 1229 | return (ctrl_type == CTRL_C_EVENT) ? (sigint_handler(SIGINT), true) : false; |
| 1230 | }; |
| 1231 | SetConsoleCtrlHandler(reinterpret_cast<PHANDLER_ROUTINE>(console_ctrl_handler), true); |
| 1232 | #endif |
| 1233 | } |
| 1234 | |
| 1235 | int main(int argc, const char ** argv) { |
| 1236 | ctrl_c_handling(); |
no test coverage detected