your post is confusing!, and as you've not posted a [https://stackoverflow.com/help/minimal-reproducible-example][1] , here's a trivial example of terminating on ^C for illustration only ...
NB:(readline already handles this by default !
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <readline/readline.h>
void trapC()
{
puts("\n^c caught, terminating!");
exit(1);
}
int main()
{
char *buff;
(void) signal(SIGINT,trapC);
for(;;)
{
buff = readline( "\nenter stuff [^C to terminate] :");
if ( buff )
printf("you entered [%s]\n", buff );
free(buff);
}
return(0);
}