I have built a function (based in a example) that allows me to ignore the signal SIGINT
. That function counts the times that the user press CONTROL + C
(the interruption SIGINT
). The function is the following one
#include <signal.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
sig_atomic_t sigint_count = 0;
void handler (int signal_number)
{
++sigint_count;
printf ("SIGINT was raised %d times\n", sigint_count);
}
int main ()
{
struct sigaction sa; //Declaração da estrutura sigaction
memset (&sa, 0, sizeof (sa));//Libertação da memória usada
sa.sa_handler = &handler;
sigaction (SIGINT, &sa, NULL);
while(1);
return 0;
}
My doubt is about this line of code
sigaction (SIGINT, &sa, NULL);
I tried to write another thing different to NULL
but it doesn't work. Why NULL
? What is the meaning of that NULL
in sigaction
?
PS: it works as I want tho