title: signal handling
body: <p>I'm just playing with signal in Mac OS X.</p>
  
  <p>Why does the following code not produce the default behavior of SIGSEGV after my signal handler has finished?
  Under Linux, the code works fine.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;signal.h&gt;
  #include &lt;stdlib.h&gt;
  
  void err_crash();
  
  void my_signal_handler (int signal)
  {
      fprintf(stderr, "signal == %i\n", signal);
      fflush(stderr);
      err_crash();
  }
  
  void err_crash()
  {
      static int count= 0;
      if (count)
          signal(SIGSEGV, SIG_DFL);       /* break recursion loop if we recursed */
      count++;
  
      // one of the two should really crash ;)
      ((void)(*((int volatile *)NULL)));
      *((int *)NULL) = 42;
  
      abort();                            /* in case we're not crashed yet... */
  }
  
  int main ()
  {
      signal(SIGSEGV, my_signal_handler);
      err_crash();
      return 0;
  }
  </code></pre>
  
  <p><strong>EDIT:</strong>
  The output I get is the following:</p>
  
  <pre><code>bonecrusher:devel sw$ g++ signal_problems.cpp -o foo
  bonecrusher:devel sw$ ./foo 
  signal == 11
  ^C
  bonecrusher:devel sw$
  </code></pre>
  
  <p>The problem is that I want that the program terminates after the output of <code>signal == 11</code>, but it rans forever and I have to interrupt it.</p>