#include #include #include #include #include void f(int); // prototype for signal handler void g(int); // prototype for signal handler bool keep_going = true; int main(int argc, char* argv[]){ signal(SIGINT, f); // install handler signal(SIGUSR1, g); // while( keep_going ){ // do nothing... } printf("go out of the infinite loop!\n"); return 0; } void f(int signum){ printf("\n\n\nsignal handler called with input %d\n\n\n", signum); if(signum == 2) keep_going = false; } void g(int sn){ printf("\n\n\nuser defined %d\n\n\n", sn); exit(sn); }