void exit(int status) { extern void (*__DTOR_LIST__[])(); void (**pfunc)() = __DTOR_LIST__; struct __atexit *a,*o; a = __atexit_ptr; __atexit_ptr = 0; /* to prevent infinite loops */ while (a) { (a->__function)(); o = a; a = a->__next; free(o); } /* Destructors should probably be called after functions registered with atexit(), this is the way it happens in Linux anyway. */ while (*++pfunc) ; while (--pfunc > __DTOR_LIST__) (*pfunc) (); /* Do this last so that everyone else may write to files during shutdown */ if (__stdio_cleanup_hook) __stdio_cleanup_hook(); ProcExitProcess(status); }
void __libc_exception_handler(void) { static bool nested; bool handled; context_t *ctx; if (nested) ProcExitProcess(0); nested = true; ctx = &ThrGetThreadInfo()->exception_info; handled = DbgHandleException(ctx); nested = false; if (handled) ThrContinue(ctx); else exit(0); }