title: Can't handle Floating Point Exception (FPE) for the second time
body: <p>I have written a program that handles signal for Floating point exception and I am using Ubuntu 10.4.</p>
  
  <p>Here's my source code :</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;signal.h&gt;
  #include &lt;setjmp.h&gt;
  
  sigjmp_buf mark;
  
  void GeneralHandler(int signo)
  {
      switch(signo)
      {
  
          case SIGFPE:
              printf("\nERROR : Invalid Arithmetic operation.\n");
              siglongjmp(mark, signo);
              break;
      }
  
      exit(signo);
  }
  
  int main(void)
  {
      int i = 0,value = 0, ans = 0;
      struct sigaction act;
      act.sa_handler = GeneralHandler;
  
      sigaction(SIGFPE, &amp;act, NULL);
  
      for(i = 0; i &lt; 10; i++)
      {
          if(sigsetjmp(mark, 1)) continue;
          printf("Value : ");
          scanf("%d" ,&amp;value);
          ans = 5 / value;
          printf("%d / %d = %d\n", 5, value, ans);
      }
  
  }
  </code></pre>
  
  <p>I am using siglongjmp and sigsetjmp methods for jumping from the handler method to the main method inside for loop.</p>
  
  <p>It works fine for the first time and displays <strong>ERROR : Invalid Arithmetic operation.</strong> and then displays <strong>Floating point exception</strong> for second time and then exits.</p>
  
  <p>Program output :</p>
  
  <blockquote>
    <p>searock@searock-desktop:~/C$ ./signal_continue<br>Value : 0<br>ERROR : Invalid Arithmetic operation.<br>Value :0<br>Floating point exception<br>  searock@searock-desktop:~/C$</p>
  </blockquote>
  
  <p>I am not sure what's wrong in my program? Why doesn't it show <strong>ERROR : Invalid Arithmetic operation.</strong> for the second time? Can someone point me in a right direction?</p>