title: Why don't I get an infinite loop when I call exit from an atexit handler?
body: <p>This program register a function calling <code>exit()</code> with <code>atexit()</code>. </p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  void machiavellian() {
      puts("At exit");
      exit(0);
  }
  int main(void) {
      atexit(machiavellian);
      exit(0);
  }
  </code></pre>
  
  <p>From <code>man atexit</code></p>
  
  <blockquote>
    <p>These callbacks must not call exit()</p>
  </blockquote>
  
  <p>I was awaiting an infinite loop, but instead, it only calls once <code>machiavellian()</code>. What happens?</p>
  
  <pre><code>$ make you_cant_exit_me
  cc     you_cant_exit_me.c   -o you_cant_exit_me
  $ ./you_cant_exit_me 
  At exit
  $ echo $?
  0
  </code></pre>