title: Enable a signal handler using sigaction in C
body: <pre><code>  struct sigaction psa;
  </code></pre>
  
  <p>I have enabled my signal handler in the main function as shown below:</p>
  
  <pre><code>    memset (&amp;psa, 0, sizeof (psa));
      psa.sa_handler = pSigHandler;
      sigaction (SIGALRM, &amp;psa, NULL);
      sigaction(SIGVTALRM, &amp;psa, NULL);
      sigaction(SIGPROF, &amp;psa, NULL);
  </code></pre>
  
  <p>My signal handler is like this:</p>
  
  <pre><code>static void pSigHandler(int signo){
      printf("Pareint signum: %d", signo);// debug
      switch (signo) {
          case SIGALRM:
              printf("P SIGALRM handler");//debug
              break;
          case SIGVTALRM:
              printf("P SIGVTALRM handler");//debug
              break;
          case SIGPROF:
              printf("P SIGPROF handler");//debug
              break;
          default: /*Should never get this case*/
              break;
      }
      return;
  }
  </code></pre>
  
  <p>Now my question may be obvious to some people, why didn't I see the printed debug lines when I run this? In fact, nothing was printed. Thank you very much for helping me to understand this. I'm running it on Linux, used Eclipse to program.</p>