title: Signal handling(SIGFPE)
body: <p>In the below code:</p>
  
  <pre><code>#include &lt;unistd.h&gt;
  #include&lt;iostream&gt;
  #include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;signal.h&gt;
  using namespace std;
  void signal_callback_handler(int signum)
  
  {
  printf ("Caught signal %d\n", signum);
  exit (signum);
  }
  
  int main()
  {
  signal (SIGFPE, signal_callback_handler);
  
  int a=4;
  int b=55444;
  
  while (1)
  {
  printf ("Program processing stuff here.\n");
  cout&lt;&lt;b/a;
  a--;
  b++;
  sleep (1);
  }
  return EXIT_SUCCESS;
  }
  </code></pre>
  
  <p>When the variable 'a' becomes 0, the program gets the SIGFPE signal from the OS and the program terminates with the message:"Caught signal 8". However, if I comment out ,the "exit(signum);" line in the 'signal_callback_handler' definition, the program keeps on running endlessly and keeps on printing "Caught Signal 8" statement on the screen. Why does this happen? Why is this signal somehow getting generated repeatedly?</p>
  
  <p>I was expecting that the signal will be generated once, and after going through the signal handler function, the program will resume after the 'cout &lt;&lt; b/a' statement and then the program will continue normally.However, since this is not happening, how can I achieve my objective?</p>