diff options
| author | kristerw <kristerw@NetBSD.org> | 2007-08-08 01:05:34 +0000 |
|---|---|---|
| committer | kristerw <kristerw@NetBSD.org> | 2007-08-08 01:05:34 +0000 |
| commit | 3a6ef3e3c19be59aadd3d337ae8b107e4c5aa259 (patch) | |
| tree | 6d398f50210c926d57a46a3062d349f1c3517e40 /lib | |
| parent | af220472c9adfb9b0f9b3c35a5dab279208e762f (diff) | |
Keep track of atexit functions that are added while processing
atexit functions, to ensure that the new functions will be called.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/libc/stdlib/atexit.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/libc/stdlib/atexit.c b/lib/libc/stdlib/atexit.c index 8f66406aa6d..a9f12d0c2ad 100644 --- a/lib/libc/stdlib/atexit.c +++ b/lib/libc/stdlib/atexit.c @@ -1,4 +1,4 @@ -/* $NetBSD: atexit.c,v 1.18 2007/08/08 00:51:18 kristerw Exp $ */ +/* $NetBSD: atexit.c,v 1.19 2007/08/08 01:05:34 kristerw Exp $ */ /*- * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -38,7 +38,7 @@ #include <sys/cdefs.h> #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: atexit.c,v 1.18 2007/08/08 00:51:18 kristerw Exp $"); +__RCSID("$NetBSD: atexit.c,v 1.19 2007/08/08 01:05:34 kristerw Exp $"); #endif /* LIBC_SCCS and not lint */ #include "reentrant.h" @@ -191,9 +191,11 @@ __cxa_finalize(void *dso) * When the depth 1 caller sees those, it will simply unlink them * for us. */ +again: for (prevp = &atexit_handler_stack; (ah = (*prevp)) != NULL;) { if (dso == NULL || dso == ah->ah_dso || ah->ah_atexit == NULL) { if (ah->ah_atexit != NULL) { + void *p = atexit_handler_stack; if (ah->ah_dso != NULL) { cxa_func = ah->ah_cxa_atexit; ah->ah_cxa_atexit = NULL; @@ -203,6 +205,9 @@ __cxa_finalize(void *dso) ah->ah_atexit = NULL; (*atexit_func)(); } + /* Restart if new atexit handler was added. */ + if (p != atexit_handler_stack) + goto again; } if (call_depth == 1) { |
