title: Printf is not working in C signal handler
body: <p>Code in question first (minimized case):</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;signal.h&gt;
  
  int counter = 0;
  
  void react_to_signal(int n) {
      fprintf(stderr, "Caught!\n");
      counter++;
  }
  
  int main(int argc, char** argv) {
  
      signal(SIGINFO, react_to_signal);
  
      while (1) {
          printf("%d\n", counter);
      }
  
      return 0;
  }
  </code></pre>
  
  <p>I run the code, it loops as it should, printing out 0. Then in another shell..</p>
  
  <pre><code>kill -s SIGINFO &lt;pid_of_my_process&gt;
  </code></pre>
  
  <p>Signal is delivered, <code>c</code> is incremented .. but the <code>fprintf</code> doesn't happen.</p>
  
  <p>Why is this so? In what environment/context does handler code run? Where can I read up on this?</p>