#ifndef WvCIARcg6KvWbOCcoxmM1lc74OI #define WvCIARcg6KvWbOCcoxmM1lc74OI #include #include volatile bool terminationRequested = false; void sigIntHandler(int sig) { terminationRequested = true; } void installSigIntHandler() { struct sigaction action; action.sa_handler = sigIntHandler; sigemptyset(&action.sa_mask); action.sa_flags = 0; assert(sigaction(SIGINT, &action, NULL) == 0); } void sigIntExit() { // restore old SIG INT handler ... struct sigaction action; action.sa_handler = SIG_DFL; sigemptyset(&action.sa_mask); action.sa_flags = 0; assert(sigaction(SIGINT, &action, NULL) == 0); // ... and use it for suicide kill(getpid(), SIGINT); } #endif // WvCIARcg6KvWbOCcoxmM1lc74OI=