signal() example | C

November 12th, 2021 12:05:22 AM

					
#include <stdio.h> #include <assert.h> #include <signal.h> void myHandler(int iSig) { printf("In myHandler with argument %d\n", iSig); } int main() { void( * pfRet)(int) = signal(SIGINT, myHandler); assert(pfRet != SIG_ERR); printf("Entering an infinite loop\n"); while (1) { printf("."); } return 0; // use CTRL+\ to exit }

Featured Posts