#include /* standard I/O functions */ #include /* standard unix functions, like getpid() */ #include /* signal name macros, and the signal() prototype */ /* first, here is the signal handler */ void catch_int(int sig_num) { /* re-set the signal handler again to catch_int, for next time */ signal(SIGINT, catch_int); printf("Don't do that\n"); fflush(stdout); } int main(int argc, char* argv[]) { /* set the INT (Ctrl-C) signal handler to 'catch_int' */ signal(SIGINT, catch_int); /* now, lets get into an infinite loop of doing nothing. */ for ( ;; ) pause(); }