diff -urp src.org/dcrt0.cc src/dcrt0.cc --- src.org/dcrt0.cc 2003-11-10 12:10:07.279150400 +0100 +++ src/dcrt0.cc 2003-11-10 12:10:57.641568000 +0100 @@ -76,6 +76,10 @@ unsigned NO_COPY _cygwin_testing_magic; char NO_COPY almost_null[1]; + +extern "C" void __sinit (struct _reent *s); + + extern "C" { /* This is an exported copy of environ which can be used by DLLs @@ -640,6 +644,9 @@ dll_crt0_1 () pthread::init_mainthread (); } + /* Initialize stdio */ + __sinit (_impure_ptr); + #ifdef DEBUGGING strace.microseconds (); #endif diff -urp src.org/thread.cc src/thread.cc --- src.org/thread.cc 2003-11-10 12:09:51.376283200 +0100 +++ src/thread.cc 2003-11-10 12:10:57.771755200 +0100 @@ -377,6 +377,9 @@ pthread::exit (void *value_ptr) mutex.unlock (); } + if (_REENT->__cleanup) + (*_REENT->__cleanup) (_REENT); + if (InterlockedDecrement (&MT_INTERFACE->threadcount) == 0) ::exit (0); else @@ -1878,6 +1881,7 @@ __reent_t::init_clib (struct _reent& var var._stdin = _GLOBAL_REENT->_stdin; var._stdout = _GLOBAL_REENT->_stdout; var._stderr = _GLOBAL_REENT->_stderr; + var.__sdidinit = _GLOBAL_REENT->__sdidinit; _clib = &var; };