// Process signals received either from the keyboard or from another process #include #include #include #include void handler(int sig) { printf("Caught signal %d\n", sig); char c; printf("Are you sure you want to quit? [y/n]\n"); scanf("%c", &c); if(c == 'y') exit(0); } int main(int argc, char *argv[]) { signal(SIGINT, handler); signal(SIGUSR1, handler); while(1) { printf("Staying alive...\n"); usleep(100 * 1000); } return 0; }