diff -urp src.old/winsup/cygwin/dll_init.cc src/winsup/cygwin/dll_init.cc --- src.old/winsup/cygwin/dll_init.cc Thu Nov 1 01:30:03 2001 +++ src/winsup/cygwin/dll_init.cc Tue Apr 16 11:41:03 2002 @@ -59,6 +59,14 @@ void per_module::run_dtors () { void (**pfunc)() = dtors; + + if( dtors_run ) + { + return; + } + + dtors_run = true; + for (int i = 1; pfunc[i]; i++) (pfunc[i]) (); } @@ -71,6 +79,8 @@ dll::init () /* Why didn't we just import this variable? */ *(p.envptr) = __cygwin_environ; + + p.dtors_run = false; /* Don't run constructors or the "main" if we've forked. */ if (!in_forkee) diff -urp src.old/winsup/cygwin/dll_init.h src/winsup/cygwin/dll_init.h --- src.old/winsup/cygwin/dll_init.h Sun Nov 4 22:39:38 2001 +++ src/winsup/cygwin/dll_init.h Tue Apr 16 11:42:57 2002 @@ -13,6 +13,7 @@ struct per_module char ***envptr; void (**ctors)(void); void (**dtors)(void); + bool dtors_run; void *data_start; void *data_end; void *bss_start; @@ -23,6 +24,7 @@ struct per_module envptr = p->envptr; ctors = p->ctors; dtors = p->dtors; + dtors_run = p->dtors_run; data_start = p->data_start; data_end = p->data_end; bss_start = p->bss_start;