title: sigaction handle signal just once
body: <p>Is there a way to catch a signal just once with <code>sigaction</code> structure and function? To be more specific, I would like to simply reset to default a specific signal (<code>SIGINT</code>). Is it possible to achieve this in a handler? </p>
  
  <h2>Edit</h2>
  
  <p>So, something like this would be correct:</p>
  
  <blockquote>
  <pre><code>void sig_int(int sig)
  {
      printf(" -&gt; Ctrl-C\n");
      struct sigaction act;
      act.sa_handler = SIG_DFL;
  
      if(sigaction(SIGINT, &amp;act, NULL) &lt; 0)
      {
          exit(-1);
      }
  
  }
  
  int main()
  {
      struct sigaction act;
      act.sa_handler = sig_int;
  
      if(sigaction(SIGINT, &amp;act, NULL) &lt; 0)
      {
          exit(-1);
      }
  
      while(1)
      {
          sleep(1);
      }
  
      return 0;   
  }
  </code></pre>
  </blockquote>