title: Why is my signal handler not working?
body: <p>I want to handle the signal SIGTSTP (18) on Linux. This is my code:</p>
  
  <pre><code>void handler(int signum){
      printf("Signal %d has tried to stop me.", signum);
  }
  
  int main(void){
      struct sigaction act;
      sigset_t mask;
  
      act.sa_handler = handler;
      act.sa_flags = 0;
  
      sigemptyset(&amp;mask);
      sigaddset(&amp;mask, SIGTSTP);
      sigprocmask(SIG_SETMASK, &amp;mask, NULL);
  
      sigaction(SIGTSTP, &amp;act, NULL);
  
      pause();
  
  }
  </code></pre>
  
  <p>When I send a signal from another terminal this way:</p>
  
  <pre><code>$ kill -18 PID
  </code></pre>
  
  <p>the handler() function does not run.
  I've tried replacing SIGTSTP with 18 in the call to sigaction(). It does not work.</p>
  
  <p>Any ideas?
  Thanks for your time.</p>