/* * external.c - A program that responds to externally * generated events (ctrl-c) */ #include #include #include #include #include "safe_printf.h" void handler(int sig) { safe_printf("You think hitting ctrl-c will stop the bomb?\n"); sleep(2); safe_printf("Well..."); sleep(1); printf("OK\n"); exit(0); } int main() { signal(SIGINT, handler); /* installs ctl-c handler */ while(1) { continue; } }