You can't do that easilychange key binding in your code because a signal is a software generated interrupt that is sent to a process by the OS. when user press ctrl-c another process tell something to your process.
There are fix set of signals that can be sent to a process. signals are similar to interrupts, the difference being that interrupts are mediated by the processor and handled by the kernel while signals are mediated by the kernel (possibly via system calls) and handled by processes. The kernel may pass an interrupt as a signal to the process that caused it (typical examples are SIGSEGV, SIGBUS, SIGILL and SIGFPE).
you can remap your interrupt keyssignal key binding in your computer with stty.
Enable Ctrl+C for copy and Ctrl+Shift+C for interrupt
https://docstore.mik.ua/orelly/unix3/upt/ch05_08.htm
if you want exactly 3 times ctrl-c. you can count SIGINT and break the program when 3 times ctrl-c pressed. (pressing three times C: CTRL +CCC).
#include<stdio.h>
#include<signal.h>
#include<unistd.h>
void sig_handler(int signo)
{
static int counter=0;
if (signo == SIGINT)
counter++;
printf("received SIGINT %d times\n", counter);
if (counter == 3)
exit(0);
}
int main()
{
if (signal(SIGINT, sig_handler) == SIG_ERR)
printf("\ncan't catch SIGINT\n");
while(1)
sleep(1);
return 0;
}