/* sigHand1.c++ Ignoring SIGINT (Ctrl-C) */ #include using namespace std; #include #include void mySigHandler(int n) { static int m = 1; if(m > 2) { signal(SIGINT, SIG_DFL); cout << "Inside handler: "<< m << "\n"; cout << "Default action after this\n"; // default } else { signal(SIGINT, mySigHandler); cout << "Inside handler: "<< m << "\n"; ++m; } } int main() { signal(SIGINT, mySigHandler) ; // mySignalHandler() while(1) { cout << "What next?...\n"; sleep(1); } return 0 ; }