public inbox for
 help / color / mirror / Atom feed
From: Wim Delvaux <>
Subject: Mingw32 : issue with atexit function in main thread
Date: Wed, 19 Dec 2012 01:00:00 -0000	[thread overview]
Message-ID: <> (raw)

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


                 reply	other threads:[~2012-12-19  1:00 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='' \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).