/* * This is mentioned in lab 10. */ #include #include #include void handle_signal(int received_signal){ printf("We received signal %d\n", received_signal); printf("Nice try!\n"); } int main(){ /* Can't do this in C++ struct sigaction action = { .sa_handler = handle_signal }; */ /* * This way to create the structure works in both C and C++ */ struct sigaction action; action.sa_handler = handle_signal; sigaction(SIGINT, &action, 0); sigaction(SIGTERM, &action, 0); while(1){ sleep(1); printf("beep!\n"); } return 0; }