I use Eclipse for C/C++ Developers version in order to write a code that has to respond to Ctrl+C click by sending the signal SIGINT. However, when I run my code from the console I find out that it doesn't respond to Ctrl+C at all. I diabled the functionality of Ctrl+C as a keymap for copy, and it still doesn't solve the problem. Do you know what I can do to solve it?
A Code example:
#include <sys/types.h>
#include <sys/wait.h>
#include <stdio.h>
static void sig_int(int num) {
printf("\nerror\n");
}
int main (int argc, char *argv[]) { //7
sigset_t zeromask;
if (signal(SIGINT, sig_int) == SIG_ERR)
fprintf(stderr,"signal(SIGINT) error");
printf("Hello\n");
if (sigsuspend(&zeromask) != -1)
fprintf(stderr,"sigsuspend error");
}
If you run this code from Linux terminal, when you click "Ctrl+C", you'll get an "error" output. However, of you run it from Eclipse console, nothing will happen. Eclipse console doesn't treat Ctrl+C as keyboard interrupt.