//* The handling control queue signals in ANSI C/C99 *

#include <signal.h> #include <stdio.h> #include <stdlib.h> // Define the function to be called when ctrl-c (SIGINT) signal is sent to process void signal_callback_handler(int signum) { // On Windows higher level IO can be used here // On *nix try to stay way from that fprintf( stdout, "Caught signal %d\n", signum ); // Cleanup and close up stuff here // Terminate program exit(signum); } int main() { // Register signal and signal handler signal( SIGINT, signal_callback_handler ); // Doing the program while(1) ; return(0); }