title: Blocking and Unblocking SIGINT and SIGQUIT
body: <p>I am writing a program that has two for loops and during the first for loop (just prints 1-5 and sleeps 1 second in between) SIGINT and SIGQUIT are to be blocked and in the second for loop only SIGINT is to be blocked. I successfully block the correct signals for the first for loop, then on the second for loop, I try to remove SIGQUIT from being blocked but both signals still seem to be blocked. </p>
  
  <p>Here is what I have as of right now:</p>
  
  <pre><code>#include &lt;unistd.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;wait.h&gt;
  #include &lt;signal.h&gt;
  #include &lt;string.h&gt;
  
  
  void hd1(int sig){
      if(sig == SIGINT){
          printf(" SIGINT Recieved\n");
      }else if(sig == SIGQUIT){
          printf(" SIGQUIT Recieved\n");
      }
  }
  
  
  int main(){
      sigset_t new_set;
      sigset_t old_set;
  
      //struct sigaction act;
      //memset(&amp;act, 0, sizeof(act));
  
      //act.sa_handler = hd1;
  
      //sigaction(SIGINT, &amp;act, 0);
      //sigaction(SIGQUIT, &amp;act, 0);
  
      sigemptyset(&amp;new_set);
      sigaddset(&amp;new_set, SIGINT);
      sigaddset(&amp;new_set, SIGQUIT);
  
      sigprocmask(SIG_BLOCK, &amp;new_set, &amp;old_set);
  
      for(int i = 1; i &lt;= 5; i++){
          printf("%d\n", i);
          sleep(1);
      }
  
  
      sigdelset(&amp;new_set, SIGQUIT);
  
  
      for(int i = 1; i &lt;= 5; i++){
          printf("%d\n", i);
          sleep(1);
      }
  }
  </code></pre>
  
  <p>I have tried using <code>sigprocmask</code> to unblock and setmask to reset the mask but it terminates the program after the loop when I unblock the signal.</p>