From dda0657380d0383935d80bf62a3d305df849bb6f Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Thu, 14 Apr 2005 17:34:03 +0000 Subject: * dcrt0.cc (do_global_dtors): Run DLL dtors. (__main): Don't rely on atexit to run dtors. (do_exit): Specifically call do_global_dtors here. (cygwin_exit): Ditto. * dll_init.cc (dll_global_dtors): Make global. Only run dtors once. (dll_list::init): Just set flag that dtors should be run. Don't rely on atexit. * dll_init.h (dll_global_dtors): Declare. * exceptions.cc (sigrelse): Define. * path.h (is_fs_device): New method. (is_lnk_special): Ditto. * fhandler_disk_file.cc (fhandler_disk_file::link): Use "is_lnk_special" rather than "is_lnk_symlink". * syscalls.cc (rename): Ditto. * hookapi.cc (ld_preload): Use colon as a separator rather than space. --- winsup/cygwin/dcrt0.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'winsup/cygwin/dcrt0.cc') diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc index c5db62c07..b24e5fe16 100644 --- a/winsup/cygwin/dcrt0.cc +++ b/winsup/cygwin/dcrt0.cc @@ -129,9 +129,11 @@ char title_buf[TITLESIZE + 1]; static void do_global_dtors (void) { - if (user_data->dtors) + dll_global_dtors (); + void (**pfunc) () = user_data->dtors; + if (pfunc) { - void (**pfunc)() = user_data->dtors; + user_data->dtors = NULL; while (*++pfunc) (*pfunc) (); } @@ -972,7 +974,6 @@ extern "C" void __main (void) { do_global_ctors (user_data->ctors, false); - atexit (do_global_dtors); } exit_states NO_COPY exit_state; @@ -994,6 +995,8 @@ do_exit (int status) EnterCriticalSection (&exit_lock); muto::set_exiting_thread (); + do_global_dtors (); + if (exit_state < ES_EVENTS_TERMINATE) { exit_state = ES_EVENTS_TERMINATE; @@ -1096,6 +1099,7 @@ cygwin_atexit (void (*function)(void)) extern "C" void cygwin_exit (int n) { + do_global_dtors (); if (atexit_lock) atexit_lock.acquire (); exit (n); -- cgit v1.2.3