title: How do I detect if a custom terminate() handler is installed?
body: <p>My code is compiled as a Windows DLL with Visual C++. I want to log rare cases when <code>terminate()</code> is being called, so I set my <code>terminate()</code> handler in the library initialization function and the latter is called by the user code before using my library. My handler writes to the log and calls <code>abort()</code> emulating the default <code>terminate()</code> behavior.</p>
  
  <p>The problem is the user code might also be written in C++ and use the very same C++ runtime version and so share the <code>terminate()</code> handler with my library. That code might also want to alter the <code>terminate()</code> handler to have their logging. So they would call <code>set_terminate()</code>, then load and initialize my library and my library would also call <code>set_terminate()</code> and override their <code>terminate()</code> handler and that will be very hard for them to detect since the <code>terminate()</code> handler is the last thing they would test I suppose.</p>
  
  <p>So I want the following. Inside the library initialization function I will <a href="https://stackoverflow.com/a/2200306/57428">retrieve the current <code>terminate()</code> handler</a>, find whether it is a standard one, then if it happens to be a non-standard one, I will store its address and later (if needed) my <code>terminate()</code> handler will write into the log and then forward the call to that custom <code>terminate()</code> handler.</p>
  
  <p>Is it possible to find if a <code>terminate()</code> handler currently installed is a default one or a custom one?</p>