aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyan Prichard <rprichard@google.com>2019-04-24 14:14:47 -0700
committerRyan Prichard <rprichard@google.com>2019-04-26 14:52:18 -0700
commit1f2ea324639f04eeee39f2b2457bc232d967d72c (patch)
treed500a5d6ffd5618faa67acdadb4a5e7cd6e0fafe
parent5bab966ca807b95ca8be32a71cc7cecc36b62106 (diff)
downloadandroid_bionic-1f2ea324639f04eeee39f2b2457bc232d967d72c.tar.gz
android_bionic-1f2ea324639f04eeee39f2b2457bc232d967d72c.tar.bz2
android_bionic-1f2ea324639f04eeee39f2b2457bc232d967d72c.zip
__cxa_finalize: skip fflush call on dlclose
In __cxa_finalize, only call fflush(NULL) when the program is exiting, not when a library is unloaded with dlclose. This change restores behavior from 2015. Flushing output is needed when the program exits, but flushing everything is hazardous at other times because it can block -- fflush(NULL) locks every file, so it also blocks on read operations. Bug: http://b/130655235 Test: manual Change-Id: I2f5ecffa6724bfd98a93d145ab5313c793c01ae6 (cherry picked from commit c5d8c6c6e47a7f5fd0c3db2a48004be1030cf753)
-rw-r--r--libc/stdlib/atexit.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/libc/stdlib/atexit.c b/libc/stdlib/atexit.c
index bd6ac3db0..692e0c0fc 100644
--- a/libc/stdlib/atexit.c
+++ b/libc/stdlib/atexit.c
@@ -186,7 +186,10 @@ restart:
}
_ATEXIT_UNLOCK();
- fflush(NULL);
+ /* If called via exit(), flush output of all open files. */
+ if (dso == NULL) {
+ fflush(NULL);
+ }
/* BEGIN android-changed: call __unregister_atfork if dso is not null */
if (dso != NULL) {