You call SIGINT by pressing Ctrl + C.
Code example:
#include <stdio.h> #include <stdlib.h> #include <signal.h> void siginthandler(int param) { printf("User pressed Ctrl+C\n"); exit(1); } int main() { signal(SIGINT, siginthandler); while(1); return 0; }
At startup:
$ ./a.out ^CUser pressed Ctrl+C $
(Note that this is pure C code, should work in C ++, though)
Edit: the only way I know to send SIGINT , besides interactively pressing Ctrl + C , uses kill(pid, SIGINT) , as you said ...
source share