* cygwin.din: Wrap atexit and exit with cygwin, thread-safe functions.

* dcrt0.cc (cygwin_atexit): New function.
(cygwin_exit): Ditto.
This commit is contained in:
Christopher Faylor
2003-03-01 02:02:42 +00:00
parent 27b4082ae7
commit 005c3065eb
5 changed files with 53 additions and 12 deletions

View File

@@ -34,6 +34,7 @@ details. */
#include "cygwin_version.h"
#include "dll_init.h"
#include "cygthread.h"
#include "sync.h"
#define MAX_AT_FILE_LEVEL 10
@@ -1064,6 +1065,28 @@ do_exit (int status)
myself->exit (n);
}
static muto *atexit_lock;
extern "C" int
cygwin_atexit (void (*function)(void))
{
int res;
if (!atexit_lock)
new_muto (atexit_lock);
atexit_lock->acquire ();
res = atexit (function);
atexit_lock->release ();
return res;
}
extern "C" void
cygwin_exit (int n)
{
if (atexit_lock)
atexit_lock->acquire ();
exit (n);
}
extern "C" void
_exit (int n)
{