yap, there is such a system call
result = signal(int signum, void(*action)(int))
<signal.h>
just use man signal
in signal.h all the possible signals are listed
//and there are some problems about how to restore the
//previous state of signal handling after a handle happened
//in some system the handle is set to default value
#include <stdio.h>
#include <signal.h>
main()
{
void f(int);
signal(SIGINT, f);
for (i = 0; i < 5; i++) {
printf("hello\n");
sleep(1);
}
}
void f(int signum)
{
printf("OUCH\n");
}
Both of those deal with catching the SIGINT signal. The OP doesn't want the signal generated in the first place. To do that, you have to modify the input stream's IGNBRK and BRKINT flags so that pressing ^C doesn't cause the input device to post a SIGINT.
I don't know whether the OP wants to stop the SIGINT at source or stop his program reacting to it.
If it's to stop the program reacting to it, I wouldn't recommend using signal(), it's the unreliable way of handling signals and bordering on depricated.
To ignore a signal in a single threaded program do something like this