#include #include #include #include int flag = 0; // Handling signal function void handle_signal(int signal) { // If signal is SIGINT if (signal == SIGQUIT) { // Set flag to its complement // Print the flag value flag = !flag; printf("Flag: %d\n", flag); } if (signal == SIGINT) { _exit(0); } } int main() { clock_t t; t = clock(); // Handling signal signal(SIGQUIT, handle_signal); signal(SIGINT, handle_signal); // Let the program run until interrupt while (1) { sleep(1); } t = clock() - t; double time_taken = ((double)t)/CLOCKS_PER_SEC; // in seconds printf("CPU Time: %f\n", t); return 0; }