summaryrefslogtreecommitdiffstats
path: root/winsup
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2009-07-30 15:48:51 +0000
committerCorinna Vinschen <corinna@vinschen.de>2009-07-30 15:48:51 +0000
commit900f20710fb10a9d02248f1a2d442c324d1fa659 (patch)
treecc9fa4046908e5246a7efc3c43a00e409f138220 /winsup
parent0986989f6a290a15e9229f65dd4846d97ee1864e (diff)
downloadcygnal-900f20710fb10a9d02248f1a2d442c324d1fa659.tar.gz
cygnal-900f20710fb10a9d02248f1a2d442c324d1fa659.tar.bz2
cygnal-900f20710fb10a9d02248f1a2d442c324d1fa659.zip
* globals.cc (enum exit_states::ES_GLOBAL_DTORS): Delete.
* dcrt0.cc (__main): Schedule dll_global_dtors to run atexit before global dtors. (do_exit): Delete test for ES_GLOBAL_DTORS and call to dll_global_dtors.
Diffstat (limited to 'winsup')
-rw-r--r--winsup/cygwin/ChangeLog8
-rw-r--r--winsup/cygwin/dcrt0.cc15
-rw-r--r--winsup/cygwin/globals.cc1
3 files changed, 17 insertions, 7 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index e8c125c6c..836c23bca 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,11 @@
+2009-07-29 Dave Korn <dave.korn.cygwin@googlemail.com>
+
+ * globals.cc (enum exit_states::ES_GLOBAL_DTORS): Delete.
+ * dcrt0.cc (__main): Schedule dll_global_dtors to run
+ atexit before global dtors.
+ (do_exit): Delete test for ES_GLOBAL_DTORS and call to
+ dll_global_dtors.
+
2009-07-29 Corinna Vinschen <corinna@vinschen.de>
* path.h (class path_conv): Convert path from char array to char *.
diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc
index 042c1a73b..9cff06f47 100644
--- a/winsup/cygwin/dcrt0.cc
+++ b/winsup/cygwin/dcrt0.cc
@@ -993,8 +993,17 @@ cygwin_dll_init ()
extern "C" void
__main (void)
{
+ /* Ordering is critical here. DLL ctors have already been
+ run as they were being loaded, so we should stack the
+ queued call to DLL dtors now. */
+ atexit (dll_global_dtors);
do_global_ctors (user_data->ctors, false);
+ /* Now we have run global ctors, register their dtors. */
atexit (do_global_dtors);
+ /* At exit, global dtors will run first, so the app can still
+ use shared library functions while terminating; then the
+ DLLs will be destroyed; finally newlib will shut down stdio
+ and terminate itself. */
}
void __stdcall
@@ -1013,12 +1022,6 @@ do_exit (int status)
lock_process until_exit (true);
- if (exit_state < ES_GLOBAL_DTORS)
- {
- exit_state = ES_GLOBAL_DTORS;
- dll_global_dtors ();
- }
-
if (exit_state < ES_EVENTS_TERMINATE)
{
exit_state = ES_EVENTS_TERMINATE;
diff --git a/winsup/cygwin/globals.cc b/winsup/cygwin/globals.cc
index ccfc20830..b50bf8460 100644
--- a/winsup/cygwin/globals.cc
+++ b/winsup/cygwin/globals.cc
@@ -30,7 +30,6 @@ enum exit_states
{
ES_NOT_EXITING = 0,
ES_PROCESS_LOCKED,
- ES_GLOBAL_DTORS,
ES_EVENTS_TERMINATE,
ES_THREADTERM,
ES_SIGNAL,