/*------------------------------------------------------------------*/ /* testsigaction.c */ /* Signal handling via the sigaction() function */ /*------------------------------------------------------------------*/ #define _GNU_SOURCE #include #include #include #include /*------------------------------------------------------------------*/ static void myHandler(int iSig) /* This function is intended to be a handler for signals of various types. Print iSig to stdout. */ { printf("In myHandler with argument %d\n", iSig); } /*------------------------------------------------------------------*/ int main(void) /* Illustrate the sigaction() function. */ { struct sigaction sAction; int iRet; sAction.sa_flags = 0; sAction.sa_handler = myHandler; sigemptyset(&sAction.sa_mask); iRet = sigaction(SIGINT, &sAction, NULL); assert(iRet == 0); printf("Entering an infinite loop\n"); for (;;) ; return 0; }