* Mingw32 : issue with atexit function in main thread
@ 2012-12-19 1:00 Wim Delvaux
0 siblings, 0 replies; only message in thread
From: Wim Delvaux @ 2012-12-19 1:00 UTC (permalink / raw)
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2012-12-19 1:00 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-19 1:00 Mingw32 : issue with atexit function in main thread Wim Delvaux
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).