diff options
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libc/stdlib/exit.c | 21 | 
1 files changed, 15 insertions, 6 deletions
diff --git a/src/lib/libc/stdlib/exit.c b/src/lib/libc/stdlib/exit.c index 0bf0d3a180..c69639125e 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) | 
| 35 | static char *rcsid = "$OpenBSD: exit.c,v 1.6 2002/07/31 18:13:16 dhartmei Exp $"; | 35 | static char *rcsid = "$OpenBSD: exit.c,v 1.7 2002/08/30 07:58:07 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 | |||
| 58 | exit(status) | 60 | exit(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); | 
