summaryrefslogtreecommitdiff
path: root/src/lib/libc/stdlib/exit.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libc/stdlib/exit.c')
-rw-r--r--src/lib/libc/stdlib/exit.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/lib/libc/stdlib/exit.c b/src/lib/libc/stdlib/exit.c
index ab53f9400b..c16b33bd30 100644
--- a/src/lib/libc/stdlib/exit.c
+++ b/src/lib/libc/stdlib/exit.c
@@ -32,9 +32,11 @@
32 */ 32 */
33 33
34#if defined(LIBC_SCCS) && !defined(lint) 34#if defined(LIBC_SCCS) && !defined(lint)
35static char *rcsid = "$OpenBSD: exit.c,v 1.4 2000/01/06 08:45:50 d Exp $"; 35static char *rcsid = "$OpenBSD: exit.c,v 1.5 2002/07/29 19:54:42 dhartmei Exp $";
36#endif /* LIBC_SCCS and not lint */ 36#endif /* LIBC_SCCS and not lint */
37 37
38#include <sys/types.h>
39#include <sys/mman.h>
38#include <stdlib.h> 40#include <stdlib.h>
39#include <unistd.h> 41#include <unistd.h>
40#include "atexit.h" 42#include "atexit.h"
@@ -58,12 +60,19 @@ void
58exit(status) 60exit(status)
59 int status; 61 int status;
60{ 62{
61 register struct atexit *p; 63 register struct atexit *p, *q;
62 register int n; 64 register int n, pgsize = getpagesize();
63 65
64 for (p = __atexit; p; p = p->next) 66 if (!__atexit_invalid) {
65 for (n = p->ind; --n >= 0;) 67 p = __atexit;
66 (*p->fns[n])(); 68 while (p != NULL) {
69 for (n = p->ind; --n >= 0;)
70 (*p->fns[n])();
71 q = p;
72 p = p->next;
73 munmap(q, pgsize);
74 }
75 }
67 if (__cleanup) 76 if (__cleanup)
68 (*__cleanup)(); 77 (*__cleanup)();
69 _exit(status); 78 _exit(status);