title: Handling signals in different ways
body: <p>Can anyone help me to understand what are the differences between the following three ways of handling a signal? I'm operating in a client/server in C.</p>
  
  <p>Edit: I've understood that the 1st example is wrong, now I'd like to know which is better/possible, the 2nd one ore the third one? I've also read around the web that someone does a mix between them, using the "struct sigaction sig" in "sigemptyset" and "sigaddset", without any sigprocmask. Is this better than both my solutions?</p>
  
  <p>Handler:</p>
  
  <pre><code>void closeSig(){
      close(socketAccept);
      close(socket);
      exit(1);
  }
  </code></pre>
  
  <p>1st example:</p>
  
  <pre><code>signal(SIGINT, closeSig);
  </code></pre>
  
  <p>2nd example:</p>
  
  <pre><code>sigset_t set;
  struct sigaction sig;
  sigemptyset(&amp;set);
  sigaddset(&amp;set, SIGINT);
  sig.sa_sigaction = &amp;closeSig;
  sig.sa_flags = SA_SIGINFO;
  sig.sa_mask = set;
  sigaction(SIGINT, &amp;sig, NULL);
  sigprocmask(SIG_UNBLOCK, &amp;set, NULL);
  </code></pre>
  
  <p>3rd example:</p>
  
  <pre><code>struct sigaction sig;
  sig.sa_sigaction = &amp;closeSig;
  sig.sa_flags = SA_SIGINFO;
  sigaction(SIGINT, &amp;sig, NULL);
  </code></pre>