summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2012-06-14 08:36:06 -0400
committerRich Felker <dalias@aerifal.cx>2012-06-14 08:36:06 -0400
commitad5a332c750550adbd45f474e5936cae65b4fd5e (patch)
tree84f9025171a2a99cb19bd94574df10ddc367f4e7 /src
parentde05a2ac22d33bd7631f182143ecea6dd01d9406 (diff)
downloadmusl-ad5a332c750550adbd45f474e5936cae65b4fd5e.tar.gz
reorder exit code to defer stdio flush until after dtors
this is required in case dtors use stdio. also remove the old comments; one was cruft from when the code used to be using function pointers and conditional calls, and has little motivation now that we're using weak symbols. the other was just complaining about having to support dtors even though the cost was made essentially zero in the non-use case by the way it's done here.
Diffstat (limited to 'src')
-rw-r--r--src/exit/exit.c5
1 files changed, 1 insertions, 4 deletions
diff --git a/src/exit/exit.c b/src/exit/exit.c
index fc291484..03c46ca5 100644
--- a/src/exit/exit.c
+++ b/src/exit/exit.c
@@ -20,13 +20,10 @@ void exit(int code)
/* If more than one thread calls exit, hang until _Exit ends it all */
while (a_swap(&lock, 1)) __syscall(SYS_pause);
- /* Only do atexit & stdio flush if they were actually used */
__funcs_on_exit();
- __fflush_on_exit();
-
- /* Destructor s**t is kept separate from atexit to avoid bloat */
if (libc.fini) libc.fini();
if (libc.ldso_fini) libc.ldso_fini();
+ __fflush_on_exit();
_Exit(code);
for(;;);