diff options
Diffstat (limited to 'src/lib/libc/stdlib/exit.c')
-rw-r--r-- | src/lib/libc/stdlib/exit.c | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/src/lib/libc/stdlib/exit.c b/src/lib/libc/stdlib/exit.c index 90b7d5adc2..83fe3d2de5 100644 --- a/src/lib/libc/stdlib/exit.c +++ b/src/lib/libc/stdlib/exit.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: exit.c,v 1.11 2005/08/08 08:05:36 espie Exp $ */ | 1 | /* $OpenBSD: exit.c,v 1.12 2007/09/03 14:40:16 millert Exp $ */ |
2 | /*- | 2 | /*- |
3 | * Copyright (c) 1990 The Regents of the University of California. | 3 | * Copyright (c) 1990 The Regents of the University of California. |
4 | * All rights reserved. | 4 | * All rights reserved. |
@@ -50,20 +50,10 @@ int __isthreaded = 0; | |||
50 | void | 50 | void |
51 | exit(int status) | 51 | exit(int status) |
52 | { | 52 | { |
53 | struct atexit *p, *q; | 53 | /* |
54 | int n, pgsize = getpagesize(); | 54 | * Call functions registered by atexit() or _cxa_atexit() |
55 | 55 | * (including the stdio cleanup routine) and then _exit(). | |
56 | if (!__atexit_invalid) { | 56 | */ |
57 | p = __atexit; | 57 | __cxa_finalize(NULL); |
58 | while (p != NULL) { | ||
59 | for (n = p->ind; --n >= 0;) | ||
60 | if (p->fns[n] != NULL) | ||
61 | (*p->fns[n])(); | ||
62 | q = p; | ||
63 | p = p->next; | ||
64 | munmap(q, pgsize); | ||
65 | } | ||
66 | } | ||
67 | /* cleanup, if registered, was called through fns[0] in the last page */ | ||
68 | _exit(status); | 58 | _exit(status); |
69 | } | 59 | } |