I have really really simple program in C, let me cope paste it from internet there:
#include <stdio.h>
#include <signal.h>
#include <stdlib.h>
#include <unistd.h>
void sigint_handler(int dummy)
{
printf("SIGINT HANDLED!\n");
signal(SIGINT,sigint_handler);
}
int main(){
signal(SIGINT,sigint_handler);
kill(getpid(),SIGINT);
sleep(1);
return 0;
}
My question is, what does this line do ?
signal(SIGINT,sigint_handler);
Is it even necessary? Without this line this program works just fine and nothing changes.