/*-------------------------------------------------------------------*/ /* testsignal.c */ /* The signal system call. */ /*-------------------------------------------------------------------*/ #include #include void mySigintHandler(int iSignal) { printf("In mySigintHandler with argument %d\n", iSignal); signal(SIGINT, mySigintHandler); } int main(int argc, char *argv[]) { signal(SIGINT, mySigintHandler); printf("Entering an infinite loop\n"); while (1) ; return 0; } /* Sample execution: $ testsignal Entering an infinite loop ^CIn mySigintHandler with argument 2 ^CIn mySigintHandler with argument 2 ^CIn mySigintHandler with argument 2 */ /* Note: Can use kill command to stop process. */