title: Why float "division-by-zero" exception wasn't caught in a function even handler was set?
body: <p>I've tried to learn the signal handling in C, when found strange behaviour. <br/>
  When x /= y; executed in the context of the main function the signal handler works. But when the same executed in some function (bad_func) handler is ignored however signal handler for SIGFPE is already set.</p>
  
  <p>Q: Why SIGFPE wasn't caught in a function by my global signal handler even _control87 was called?</p>
  
  <p>(MS VC 2010):</p>
  
  <pre><code>#include "stdafx.h"
  #include &lt;stdlib.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;signal.h&gt;
  #include &lt;setjmp.h&gt;
  #include &lt;float.h&gt;
  
  jmp_buf g_jb_MainFunc;
  
  void hook_zd (int i)
  {
      printf("Result :%i\n",i);
      longjmp(g_jb_MainFunc, 5);
  }
  void bad_func(void)
  {
      double x = 0., y = 0.;
      puts("hello1");
      //abort();
      x /= y;
      puts("bye1");
  }
  int main(int argc, char* argv[])
  {
      double x = 0., y = 0.;
      signal(SIGFPE, hook_zd);
      signal(SIGABRT, hook_zd);
      puts("hello");
      _control87(0, _MCW_EM );
      int res;
      if (! (res = setjmp(g_jb_MainFunc)))
      {
          //abort();
          //x /= y;
          bad_func();
      } else
      {
          printf("Jumped here from: %i\n",res);
      }
      puts("bye");
  
      return 0;
  }
  </code></pre>