This is the mail archive of the pthreads-win32@sourceware.org mailing list for the pthreas-win32 project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Mingw32 : issue with atexit function in main thread


Hi all,

I have this C - program that uses a dll library of my own, originally
created on a Linux platform.

This DLL library creates some internal threads.  The main program does
not know of the existence of these threads.

To cleanup these threads (and other resources), the current
implementation of that library registers a cleanup function using the
atexit C function.

The idea is that when the program returns from main after it has
finished doing its business, the library gets the last word to do its
own cleanup work.

What happens in Mingw is that the internal threads is still alive just
before the return from main but somewhere between
the return and the call of atexit cleanup function, the threads are stopped.

I checked the source code of pthread and I think it has something to
do with the pthread_win32_process_detach_np function that gets
executed when the pthread dll gets unloaded ( or something like that).

Is there any way I can reproduce get the atexit behavior i.e. that the
cleanup function gets called *before* the threads
are terminated by the pthread dll ?

Or is there another (non portable ?) way I can register a cleanup
function to the mingw specific pthread implementation by not using
atexit but something else ?

And of course ... how can I do this ?

Any help appreciated

Wim


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]