summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorespie <espie@openbsd.org>2004-01-26 20:04:11 +0000
committerespie <espie@openbsd.org>2004-01-26 20:04:11 +0000
commit50663d24c4887a5a9630d0915e63bf2db0ea1af0 (patch)
treee0bf4581ff7e405c2af5ad7835049a7999c454c1 /lib
parentsmall clean-up: typedef to desambiguate const, prototypes... (diff)
downloadwireguard-openbsd-50663d24c4887a5a9630d0915e63bf2db0ea1af0.tar.xz
wireguard-openbsd-50663d24c4887a5a9630d0915e63bf2db0ea1af0.zip
add finalized guard to destructor calls, to prevent multiple calls.
stop most kde apps from burping all over the place on exit, which means that, somehow, our destructors get registered twice... :-( Okay drahn@
Diffstat (limited to 'lib')
-rw-r--r--lib/csu/common_elf/crtbegin.c15
-rw-r--r--lib/csu/common_elf/crtbeginS.c16
-rw-r--r--lib/csu/common_elf/crtend.c2
-rw-r--r--lib/csu/common_elf/crtendS.c2
-rw-r--r--lib/csu/crtbegin.c15
-rw-r--r--lib/csu/crtbeginS.c16
-rw-r--r--lib/csu/crtend.c2
-rw-r--r--lib/csu/crtendS.c2
8 files changed, 44 insertions, 26 deletions
diff --git a/lib/csu/common_elf/crtbegin.c b/lib/csu/common_elf/crtbegin.c
index 834f8a1e3db..df53b5220b9 100644
--- a/lib/csu/common_elf/crtbegin.c
+++ b/lib/csu/common_elf/crtbegin.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: crtbegin.c,v 1.8 2004/01/26 20:00:37 espie Exp $ */
+/* $OpenBSD: crtbegin.c,v 1.9 2004/01/26 20:04:11 espie Exp $ */
/* $NetBSD: crtbegin.c,v 1.1 1996/09/12 16:59:03 cgd Exp $ */
/*
@@ -111,9 +111,14 @@ __do_init()
void
__do_fini()
{
- /*
- * Call global destructors.
- */
- (__dtors)();
+ static int finalized = 0;
+
+ if (!finalized) {
+ finalized = 1;
+ /*
+ * Call global destructors.
+ */
+ (__dtors)();
+ }
}
diff --git a/lib/csu/common_elf/crtbeginS.c b/lib/csu/common_elf/crtbeginS.c
index b9f2e61e4b9..f8151b21e10 100644
--- a/lib/csu/common_elf/crtbeginS.c
+++ b/lib/csu/common_elf/crtbeginS.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: crtbeginS.c,v 1.6 2004/01/26 20:00:37 espie Exp $ */
+/* $OpenBSD: crtbeginS.c,v 1.7 2004/01/26 20:04:11 espie Exp $ */
/* $NetBSD: crtbegin.c,v 1.1 1996/09/12 16:59:03 cgd Exp $ */
/*
@@ -108,9 +108,13 @@ _do_init(void)
void
_do_fini(void)
{
- /*
- * since the _init() function sets up the destructors to be called
- * by atexit, do not call the destructors here.
- */
- __dtors();
+ static int finalized = 0;
+ if (!finalized) {
+ finalized = 1;
+ /*
+ * since the _init() function sets up the destructors to
+ * be called by atexit, do not call the destructors here.
+ */
+ __dtors();
+ }
}
diff --git a/lib/csu/common_elf/crtend.c b/lib/csu/common_elf/crtend.c
index 7c751465c7d..4f9cfe6deed 100644
--- a/lib/csu/common_elf/crtend.c
+++ b/lib/csu/common_elf/crtend.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: crtend.c,v 1.4 2004/01/26 20:00:37 espie Exp $ */
+/* $OpenBSD: crtend.c,v 1.5 2004/01/26 20:04:11 espie Exp $ */
/* $NetBSD: crtend.c,v 1.1 1996/09/12 16:59:04 cgd Exp $ */
#include <sys/cdefs.h>
diff --git a/lib/csu/common_elf/crtendS.c b/lib/csu/common_elf/crtendS.c
index 1137b450202..2701bf45b37 100644
--- a/lib/csu/common_elf/crtendS.c
+++ b/lib/csu/common_elf/crtendS.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: crtendS.c,v 1.4 2004/01/26 20:00:37 espie Exp $ */
+/* $OpenBSD: crtendS.c,v 1.5 2004/01/26 20:04:11 espie Exp $ */
/* $NetBSD: crtend.c,v 1.1 1997/04/16 19:38:24 thorpej Exp $ */
#include <sys/cdefs.h>
diff --git a/lib/csu/crtbegin.c b/lib/csu/crtbegin.c
index 834f8a1e3db..df53b5220b9 100644
--- a/lib/csu/crtbegin.c
+++ b/lib/csu/crtbegin.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: crtbegin.c,v 1.8 2004/01/26 20:00:37 espie Exp $ */
+/* $OpenBSD: crtbegin.c,v 1.9 2004/01/26 20:04:11 espie Exp $ */
/* $NetBSD: crtbegin.c,v 1.1 1996/09/12 16:59:03 cgd Exp $ */
/*
@@ -111,9 +111,14 @@ __do_init()
void
__do_fini()
{
- /*
- * Call global destructors.
- */
- (__dtors)();
+ static int finalized = 0;
+
+ if (!finalized) {
+ finalized = 1;
+ /*
+ * Call global destructors.
+ */
+ (__dtors)();
+ }
}
diff --git a/lib/csu/crtbeginS.c b/lib/csu/crtbeginS.c
index b9f2e61e4b9..f8151b21e10 100644
--- a/lib/csu/crtbeginS.c
+++ b/lib/csu/crtbeginS.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: crtbeginS.c,v 1.6 2004/01/26 20:00:37 espie Exp $ */
+/* $OpenBSD: crtbeginS.c,v 1.7 2004/01/26 20:04:11 espie Exp $ */
/* $NetBSD: crtbegin.c,v 1.1 1996/09/12 16:59:03 cgd Exp $ */
/*
@@ -108,9 +108,13 @@ _do_init(void)
void
_do_fini(void)
{
- /*
- * since the _init() function sets up the destructors to be called
- * by atexit, do not call the destructors here.
- */
- __dtors();
+ static int finalized = 0;
+ if (!finalized) {
+ finalized = 1;
+ /*
+ * since the _init() function sets up the destructors to
+ * be called by atexit, do not call the destructors here.
+ */
+ __dtors();
+ }
}
diff --git a/lib/csu/crtend.c b/lib/csu/crtend.c
index 7c751465c7d..4f9cfe6deed 100644
--- a/lib/csu/crtend.c
+++ b/lib/csu/crtend.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: crtend.c,v 1.4 2004/01/26 20:00:37 espie Exp $ */
+/* $OpenBSD: crtend.c,v 1.5 2004/01/26 20:04:11 espie Exp $ */
/* $NetBSD: crtend.c,v 1.1 1996/09/12 16:59:04 cgd Exp $ */
#include <sys/cdefs.h>
diff --git a/lib/csu/crtendS.c b/lib/csu/crtendS.c
index 1137b450202..2701bf45b37 100644
--- a/lib/csu/crtendS.c
+++ b/lib/csu/crtendS.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: crtendS.c,v 1.4 2004/01/26 20:00:37 espie Exp $ */
+/* $OpenBSD: crtendS.c,v 1.5 2004/01/26 20:04:11 espie Exp $ */
/* $NetBSD: crtend.c,v 1.1 1997/04/16 19:38:24 thorpej Exp $ */
#include <sys/cdefs.h>