



(81 votes)/* * Example program by pipas@linux.pte.hu * This program is uninterruptable with * Ctrl+C, uses signal handler * * http://www.metalshell.com/ */ #include <stdio.h> #include <signal.h> #include <unistd.h> /* The signal handler function */ void handler( int signal ) { printf("Signal handler...\n"); psignal( signal, "Signal: "); } /*handler*/ main() { /* Registering the handler, catching SIGINT signals */ signal( SIGINT, handler ); /* Do nothing */ while( 1 ) { printf("Running...\n"); sleep(10); } /*while*/ } /*main*/