* 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.
This commit is contained in:
Christopher Faylor
2005-04-14 17:34:03 +00:00
parent 3178cfffc8
commit dda0657380
10 changed files with 62 additions and 18 deletions

View File

@ -24,14 +24,17 @@ extern void __stdcall check_sanity_and_sync (per_process *);
dll_list NO_COPY dlls;
static int NO_COPY in_forkee;
static int dll_global_dtors_recorded;
static bool dll_global_dtors_recorded;
/* Run destructors for all DLLs on exit. */
static void
void
dll_global_dtors ()
{
for (dll *d = dlls.istart (DLL_ANY); d; d = dlls.inext ())
d->p.run_dtors ();
int recorded = dll_global_dtors_recorded;
dll_global_dtors_recorded = false;
if (recorded)
for (dll *d = dlls.istart (DLL_ANY); d; d = dlls.inext ())
d->p.run_dtors ();
}
/* Run all constructors associated with a dll */
@ -215,12 +218,7 @@ dll_list::detach (void *retaddr)
void
dll_list::init ()
{
/* Make sure that destructors are called on exit. */
if (!dll_global_dtors_recorded)
{
atexit (dll_global_dtors);
dll_global_dtors_recorded = 1;
}
dll_global_dtors_recorded = true;
/* Walk the dll chain, initializing each dll */
dll *d = &start;