title: Who called atexit()?
body: <p>I have a C program that quits unexpectedly on Linux and I have a hard time finding out why (no core dump, see <a href="https://stackoverflow.com/questions/25790890/xio-fatal-io-error-11">XIO: fatal IO error 11</a>). I placed an atexit() at the beginning of the program and the callback function is indeed being called when the crash happens.</p>
  
  <p>How can I know what called the atexit callback function? From reading the man page, atexit is called at exit (d'ho!) or return from main. I can exclude the latter because there are a bunch of printf at the end of the main and I don't see them. And I can exclude the former simply because there aren't any exit() in my program.</p>
  
  <p>That leaves only one solution: exit is being called from a library function. Is that the only possibility? And how can I know from where? Is it possible to print out a stack trace or force a core dump from inside the atexit callback?</p>