#include <signal.h>
static void handler(int sig)
{
...
}
int main(void)
{
int state;
struct sigaction act;
act.sa_handler=handler;
sigemptyset(&act.sa_mask);
act.sa_flags=0;
state=sigaction(SIGINT, &act, 0);
if(state != 0){
puts("sigaction() error ");
exit(1);
}
...
}