#include #include #include static int alarm_fired = 0; void ding(int sig) { alarm_fired = 1; printf("ding...."); } /* In main, we tell the child process to wait for five seconds before sending a SIGALRM signal to its parent. */ int main() { printf("waiting for alarm to go off\n"); (void) signal(SIGINT, ding); int i; for (i=0;i<15;i++){ sleep(1); } if (alarm_fired) printf("Ding!\n"); printf("done\n"); exit(0); }